table_index.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. /****
  39. * @return array
  40. * wanggangtao
  41. *
  42. */
  43. public function getIndexList(){
  44. $where="where 1=1";
  45. $sql = "select "."`*`". "from ". $this->table_fullname ." $where order by ".$this->table_id." asc";
  46. $rs = $this->pdo->sqlQuery($sql);
  47. $r = array();
  48. if($rs){
  49. foreach($rs as $key => $val){
  50. $r[$key] = $this->dataToAttr($val);
  51. }
  52. return $r;
  53. }else{
  54. return $r;
  55. }
  56. }
  57. public function get_index_info($index_type){
  58. $where=" where 1=1 ";
  59. $sql = "select "."`*`". "from ". $this->table_fullname . $where ;
  60. if($index_type==1){
  61. $stock_code="000001";
  62. $sql.=" and index_code=".$stock_code ;
  63. }else if($index_type==2){
  64. $stock_code="399001";
  65. $sql.=" and index_code=".$stock_code ;
  66. }else if($index_type==3){
  67. $stock_code="000016";
  68. $sql.=" and index_code=".$stock_code ;
  69. }else if($index_type==4){
  70. $stock_code="399300";
  71. $sql.=" and index_code=".$stock_code ;
  72. }else if($index_type==5){
  73. $stock_code="399006";
  74. $sql.=" and index_code=".$stock_code ;
  75. }else if($index_type==6){
  76. $stock_code="000688";
  77. $sql.=" and index_code=".$stock_code ;
  78. }
  79. $rs = $this->pdo->sqlQuery($sql);
  80. $r = array();
  81. if($rs){
  82. foreach($rs as $key => $val){
  83. $r[$key] = $this->dataToAttr($val);
  84. }
  85. return $r;
  86. }else{
  87. return $r;
  88. }
  89. }
  90. }
  91. ?>