stock.class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 update($stock_code,$attrs)
  17. {
  18. if (empty($attrs)) throw new Exception('参数不能为空', 102);
  19. $Table_stock = new Table_stock();
  20. $id = $Table_stock->update($stock_code,$attrs);
  21. return $id;
  22. }
  23. static public function add($attrs)
  24. {
  25. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  26. $Table_stock = new Table_stock();
  27. $id = $Table_stock->add($attrs);
  28. return $id;
  29. }
  30. static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
  31. {
  32. $Table_stock = new Table_stock();
  33. return $Table_stock->getList($filter, $count, $page, $pageSize);
  34. }
  35. /****
  36. * @param array $filter
  37. * @param int $count
  38. * @param int $page
  39. * @param int $pageSize
  40. * @return array|int
  41. * 获取股票的代码列表
  42. */
  43. static public function getStockCodeList()
  44. {
  45. $Table_stock = new Table_stock();
  46. return $Table_stock->getStockCodeList();
  47. }
  48. static public function updateCodeAndName($attrs)
  49. {
  50. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  51. $Table_stock = new Table_stock();
  52. $rs = $Table_stock->getInfoByCode($attrs['code']);
  53. if (empty($rs)) {
  54. $id = $Table_stock->addCodeAndName($attrs);
  55. } else {
  56. $id = $rs['id'];
  57. $Table_stock->update($id, $attrs);
  58. }
  59. return $id;
  60. }
  61. }
  62. ?>