stock.class.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /***
  3. * Class Stock
  4. * * @author 王刚涛
  5. * 日线数据
  6. */
  7. class Stock {
  8. public function __construct()
  9. {
  10. }
  11. static public function getInfoById($id)
  12. {
  13. $Table_stock = new Table_stock();
  14. return $Table_stock->getInfoById($id);
  15. }
  16. static public function add($attrs)
  17. {
  18. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  19. $Table_stock = new Table_stock();
  20. $id = $Table_stock->add($attrs);
  21. return $id;
  22. }
  23. static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
  24. {
  25. $Table_stock = new Table_stock();
  26. return $Table_stock->getList($filter, $count, $page, $pageSize);
  27. }
  28. /****
  29. * @param array $filter
  30. * @param int $count
  31. * @param int $page
  32. * @param int $pageSize
  33. * @return array|int
  34. * 获取股票的代码列表
  35. */
  36. static public function getStockCodeList()
  37. {
  38. $Table_stock = new Table_stock();
  39. return $Table_stock->getStockCodeList();
  40. }
  41. static public function updateCodeAndName($attrs)
  42. {
  43. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  44. $Table_stock = new Table_stock();
  45. $rs = $Table_stock->getInfoByCode($attrs['code']);
  46. if (empty($rs)) {
  47. $id = $Table_stock->addCodeAndName($attrs);
  48. } else {
  49. $id = $rs['id'];
  50. $Table_stock->update($id, $attrs);
  51. }
  52. return $id;
  53. }
  54. }
  55. ?>