| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- /***
- * Class Stock
- * * @author 王刚涛
- * 日线数据
- */
- class Stock {
- public function __construct()
- {
- }
- static public function getInfoById($id)
- {
- $Table_stock = new Table_stock();
- return $Table_stock->getInfoById($id);
- }
- static public function update($stock_id,$attrs)
- {
- if (empty($attrs)) throw new Exception('参数不能为空', 102);
- $Table_stock = new Table_stock();
- $id = $Table_stock->update($stock_id,$attrs);
- return $id;
- }
- /***
- * @param $stock_code
- * @param $attrs
- * @return mixed
- * @throws Exception
- * 更新部分静态数据
- */
- static public function updateByCode($stock_code,$attrs)
- {
- if (empty($attrs)) throw new Exception('参数不能为空', 102);
- $Table_stock = new Table_stock();
- $id = $Table_stock->updateByCode($stock_code,$attrs);
- return $id;
- }
- static public function add($attrs)
- {
- if (empty($attrs)) throw new Exception('参数不能为空', 101);
- $Table_stock = new Table_stock();
- $id = $Table_stock->add($attrs);
- return $id;
- }
- static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
- {
- $Table_stock = new Table_stock();
- return $Table_stock->getList($filter, $count, $page, $pageSize);
- }
- /****
- * @param array $filter
- * @param int $count
- * @param int $page
- * @param int $pageSize
- * @return array|int
- * 获取股票的代码列表
- */
- static public function getStockCodeList()
- {
- $Table_stock = new Table_stock();
- return $Table_stock->getStockCodeList();
- }
- static public function updateCodeAndName($attrs)
- {
- if (empty($attrs)) throw new Exception('参数不能为空', 101);
- $Table_stock = new Table_stock();
- $rs = $Table_stock->getInfoByCode($attrs['code']);
- if (empty($rs)) {
- $id = $Table_stock->addCodeAndName($attrs);
- } else {
- $id = $rs['id'];
- $Table_stock->update($id, $attrs);
- }
- return $id;
- }
- }
- ?>
|