table_index.class.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * 数据库表:管理员组
  4. *
  5. * @createtime 2018/03/01
  6. * @author 空竹
  7. * @copyright 芝麻开发(http://www.zhimawork.com)
  8. */
  9. class Table_index extends Table {
  10. protected $table_name = 'index';//表名,不带前缀,前缀在config中定义
  11. protected $table_id = 'index_id';//指定ID字段名称,必须
  12. protected $table_status = '';//指定状态字段名称,如果有
  13. protected $table_order = '';//指定排序字段名称,如果有
  14. //数据库结构
  15. protected function struct(){
  16. $attr = array();
  17. $attr['id'] = 'index_id';
  18. $attr['code'] = 'index_code';
  19. $attr['name'] = 'index_name';
  20. $attr['exchange'] = 'index_exchange';
  21. $attr['sector'] = 'index_sector';
  22. return $attr;
  23. }
  24. public function add($attr){
  25. $param = array (
  26. 'index_date' => array('number', $attr['date']),
  27. 'index_open_price' => array('number', $attr['open_price']),
  28. 'index_close_price' => array('number', $attr['close_price']),
  29. 'index_highest_price' => array('number', $attr['highest_price']),
  30. 'index_lowest_price' => array('number', $attr['lowest_price']),
  31. 'index_increase_value' => array('number', $attr['increase_value']),
  32. 'index_increase_price' => array('number', $attr['increase_price']),
  33. 'index_amount' => array('number', $attr['amount']),
  34. 'index_value' => array('number', $attr['value']),
  35. );
  36. return $this->pdo->sqlinsert($this->table_fullname, $param);
  37. }
  38. public function getIndexList(){
  39. $where="where 1=1";
  40. $sql = "select "."`*`". "from ". $this->table_fullname ." $where order by ".$this->table_id." asc";
  41. $rs = $this->pdo->sqlQuery($sql);
  42. $r = array();
  43. if($rs){
  44. foreach($rs as $key => $val){
  45. $r[$key] = $this->dataToAttr($val);
  46. }
  47. return $r;
  48. }else{
  49. return $r;
  50. }
  51. }
  52. }
  53. ?>