stock.class.php 2.0 KB

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