|
|
@@ -15,6 +15,20 @@ class Table_stock extends Table {
|
|
|
protected $table_status = '';//指定状态字段名称,如果有
|
|
|
protected $table_order = '';//指定排序字段名称,如果有
|
|
|
|
|
|
+ protected function struct2(){
|
|
|
+ $attr = array();
|
|
|
+ $attr['code'] = 'stock_code';
|
|
|
+ return $attr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //从数据库取出的数据转化键值后输出
|
|
|
+ protected function dataToAttr2($data){
|
|
|
+ $r = array();
|
|
|
+ foreach(self::struct2() as $k => $v){
|
|
|
+ $r[$k] = $data[$v];
|
|
|
+ }
|
|
|
+ return $r;
|
|
|
+ }
|
|
|
//数据库结构
|
|
|
protected function struct(){
|
|
|
$attr = array();
|
|
|
@@ -57,21 +71,28 @@ class Table_stock extends Table {
|
|
|
return $this->pdo->sqlinsert($this->table_fullname, $param);
|
|
|
}
|
|
|
|
|
|
+ /***
|
|
|
+ * @param array $filter
|
|
|
+ * @param int $count
|
|
|
+ * @param int $page
|
|
|
+ * @param int $pagesize
|
|
|
+ * @return array
|
|
|
+ * 获取代码列表
|
|
|
+ */
|
|
|
public function getStockCodeList($filter = array(), $count = 0, $page = 0, $pagesize = 0){
|
|
|
|
|
|
$where="where 1=1";
|
|
|
$sql = "select "."`stock_code`". "from ". $this->table_fullname ." $where order by ".$this->table_id." desc";
|
|
|
$rs = $this->pdo->sqlQuery($sql);
|
|
|
- $r = array();
|
|
|
+ $r = array();
|
|
|
if($rs){
|
|
|
foreach($rs as $key => $val){
|
|
|
- $r[$key] = $this->dataToAttr($val);
|
|
|
+ $r[$key] = $this->dataToAttr2($val);
|
|
|
}
|
|
|
return $r;
|
|
|
}else{
|
|
|
return $r;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public function addCodeAndName($attr){
|