| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- /**
- * 数据库表:管理员组
- *
- * @createtime 2018/03/01
- * @author 空竹
- * @copyright 芝麻开发(http://www.zhimawork.com)
- */
- class Table_index extends Table {
- protected $table_name = 'index';//表名,不带前缀,前缀在config中定义
- protected $table_id = 'index_id';//指定ID字段名称,必须
- protected $table_status = '';//指定状态字段名称,如果有
- protected $table_order = '';//指定排序字段名称,如果有
- //数据库结构
- protected function struct(){
- $attr = array();
-
- $attr['id'] = 'index_id';
- $attr['code'] = 'index_code';
- $attr['name'] = 'index_name';
- $attr['exchange'] = 'index_exchange';
- $attr['sector'] = 'index_sector';
- return $attr;
- }
- public function add($attr){
- $param = array (
- 'index_date' => array('number', $attr['date']),
- 'index_open_price' => array('number', $attr['open_price']),
- 'index_close_price' => array('number', $attr['close_price']),
- 'index_highest_price' => array('number', $attr['highest_price']),
- 'index_lowest_price' => array('number', $attr['lowest_price']),
- 'index_increase_value' => array('number', $attr['increase_value']),
- 'index_increase_price' => array('number', $attr['increase_price']),
- 'index_amount' => array('number', $attr['amount']),
- 'index_value' => array('number', $attr['value']),
- );
- return $this->pdo->sqlinsert($this->table_fullname, $param);
- }
- /****
- * @return array
- * wanggangtao
- *
- */
- public function getIndexList(){
- $where="where 1=1";
- $sql = "select "."`*`". "from ". $this->table_fullname ." $where order by ".$this->table_id." asc";
- $rs = $this->pdo->sqlQuery($sql);
- $r = array();
- if($rs){
- foreach($rs as $key => $val){
- $r[$key] = $this->dataToAttr($val);
- }
- return $r;
- }else{
- return $r;
- }
- }
- /***
- * @param $code
- * @return array
- * 获取指数的基本信息
- */
- public function get_index_info($code){
- $where=" where 1=1 ";
- $sql = "select "."`*`". "from ". $this->table_fullname . $where ;
- $sql.=" and index_code=".$code ;
- $rs = $this->pdo->sqlQuery($sql);
- $r = array();
- if($rs){
- foreach($rs as $key => $val){
- $r[$key] = $this->dataToAttr($val);
- }
- return $r[0];
- }else{
- return $r;
- }
- }
- }
- ?>
|