Procházet zdrojové kódy

增加baseconfig表

chenbo před 4 roky
rodič
revize
cb878f215f

+ 41 - 0
lib/baseconfig.class.php

@@ -0,0 +1,41 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: wangming
+ * Date: 2019/1/22
+ * Time: 21:34
+ */
+
+class Baseconfig{
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getInfoById($id)
+    {
+        $Table_baseconfig = new Table_baseconfig();
+        return $Table_baseconfig->getInfoById($id);
+    }
+
+    static public function getInfoByKey($openId)
+    {
+        $Table_baseconfig = new Table_baseconfig();
+        return $Table_baseconfig->getInfoByKey($openId);
+    }
+
+    static public function add($attrs)
+    {
+        $Table_baseconfig = new Table_baseconfig();
+        $id = $Table_baseconfig->add($attrs);
+        return $id;
+    }
+
+    static public function update($id, $attrs)
+    {
+        $Table_baseconfig = new Table_baseconfig();
+        return $Table_baseconfig->update($id, $attrs);
+    }
+
+}

+ 75 - 0
lib/table/table_baseconfig.class.php

@@ -0,0 +1,75 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: wangming
+ * Date: 2019/1/22
+ * Time: 20:54
+ */
+
+
+
+class Table_baseconfig extends Table
+{
+
+    protected $table_name = 'baseconfig';//表名
+    protected $table_id = 'baseconfig_id';//指定ID字段名称,必须
+    protected $table_status = '';//指定状态字段名称,如果有
+    protected $table_order = '';//指定排序字段名称,如果有
+
+
+    //数据库结构
+    protected function struct()
+    {
+        $attr = array();
+
+        $attr['id']    = 'baseconfig_id';
+        $attr['key']   = 'baseconfig_key';
+        $attr['value'] = 'baseconfig_value';
+
+        return $attr;
+    }
+
+    public function getInfoByKey($key)
+    {
+
+        $key = $this->pdo->sql_check_input(array('string', $key));
+
+        $sql = "select * from " . $this->table_fullname . " where baseconfig_key = $key limit 1";
+
+        $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;
+        }
+    }
+
+    public function add($attr)
+    {
+        $param = array(
+            'baseconfig_key'   => array('string', $attr['key']),
+            'baseconfig_value' => array('string', $attr['value']),
+        );
+
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+    public function update($id, $attr)
+    {
+        $param = array(
+            'baseconfig_key'   => array('string', $attr['key']),
+            'baseconfig_value' => array('string', $attr['value']),
+        );
+
+        $where = array(
+            'baseconfig_id' => array('number', $id)
+        );
+
+        return $this->pdo->sqlupdate($this->table_fullname, $param, $where);
+    }
+
+}

+ 2 - 2
lib/table/table_reader.class.php

@@ -11,8 +11,8 @@
 class Table_reader extends Table
 {
 
-    protected $table_name = 'fission';//表名
-    protected $table_id = 'fission_id';//指定ID字段名称,必须
+    protected $table_name = 'reader';//表名
+    protected $table_id = 'reader_id';//指定ID字段名称,必须
     protected $table_status = '';//指定状态字段名称,如果有
     protected $table_order = '';//指定排序字段名称,如果有