stock.class.php 891 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /***
  3. * Class Stock
  4. * * @author 王刚涛
  5. * 日线数据
  6. */
  7. class Stock {
  8. static public function getInfoById($id)
  9. {
  10. $Table_stock = new Table_stock();
  11. return $Table_stock->getInfoById($id);
  12. }
  13. static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
  14. {
  15. $Table_stock = new Table_stock();
  16. return $Table_stock->getList($filter, $count, $page, $pageSize);
  17. }
  18. static public function addOrUpdateByCode($attrs)
  19. {
  20. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  21. $Table_stock = new Table_stock();
  22. $rs = $Table_stock->getInfoByCode($attrs['code']);
  23. if (empty($rs)) {
  24. $id = $Table_stock->add($attrs);
  25. } else {
  26. $id = $rs['id'];
  27. $Table_stock->update($id, $attrs);
  28. }
  29. return $id;
  30. }
  31. }
  32. ?>