|
|
@@ -8,11 +8,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
-class Table_common_guest extends Table
|
|
|
+class Table_reader extends Table
|
|
|
{
|
|
|
|
|
|
- protected $table_name = 'common_guest';//表名
|
|
|
- protected $table_id = 'common_guest_id';//指定ID字段名称,必须
|
|
|
+ protected $table_name = 'fission';//表名
|
|
|
+ protected $table_id = 'fission_id';//指定ID字段名称,必须
|
|
|
protected $table_status = '';//指定状态字段名称,如果有
|
|
|
protected $table_order = '';//指定排序字段名称,如果有
|
|
|
|
|
|
@@ -22,22 +22,13 @@ class Table_common_guest extends Table
|
|
|
{
|
|
|
$attr = array();
|
|
|
|
|
|
- $attr['id'] = 'common_guest_id';
|
|
|
- $attr['code'] = 'common_guest_code';
|
|
|
- $attr['phone'] = 'common_guest_phone';
|
|
|
- $attr['wxopenid'] = 'common_guest_wxopenid';
|
|
|
- $attr['name'] = 'common_guest_name';
|
|
|
- $attr['sex'] = 'common_guest_sex';
|
|
|
- $attr['province'] = 'common_guest_province';
|
|
|
- $attr['city'] = 'common_guest_city';
|
|
|
- $attr['detailaddress'] = 'common_guest_detailaddress';
|
|
|
- $attr['hangye_id'] = 'common_guest_hangye_id';
|
|
|
- $attr['addtime'] = 'common_guest_addtime';
|
|
|
- $attr['count'] = 'common_guest_count';
|
|
|
-
|
|
|
- //外键字段
|
|
|
- $attr['hangye_name'] = 'hangye_name';
|
|
|
-
|
|
|
+ $attr['id'] = 'reader_id';
|
|
|
+ $attr['phone'] = 'reader_phone';
|
|
|
+ $attr['wxopenid'] = 'reader_wxopenid';
|
|
|
+ $attr['name'] = 'reader_name';
|
|
|
+ $attr['sex'] = 'reader_sex';
|
|
|
+ $attr['addtime'] = 'reader_addtime';
|
|
|
+ $attr['count'] = 'reader_count';
|
|
|
|
|
|
return $attr;
|
|
|
}
|
|
|
@@ -47,7 +38,7 @@ class Table_common_guest extends Table
|
|
|
|
|
|
$id = $this->pdo->sql_check_input(array('number', $id));
|
|
|
|
|
|
- $sql = "select * from " . $this->table_fullname . " where common_guest_id = $id limit 1";
|
|
|
+ $sql = "select * from " . $this->table_fullname . " where reader_id = $id limit 1";
|
|
|
|
|
|
$rs = $this->pdo->sqlQuery($sql);
|
|
|
$r = array();
|
|
|
@@ -66,7 +57,7 @@ class Table_common_guest extends Table
|
|
|
|
|
|
$phone = $this->pdo->sql_check_input(array('string', $phone));
|
|
|
|
|
|
- $sql = "select * from " . $this->table_fullname . " where common_guest_phone = $phone limit 1";
|
|
|
+ $sql = "select * from " . $this->table_fullname . " where reader_phone = $phone limit 1";
|
|
|
|
|
|
$rs = $this->pdo->sqlQuery($sql);
|
|
|
$r = array();
|
|
|
@@ -85,7 +76,7 @@ class Table_common_guest extends Table
|
|
|
|
|
|
$openId = $this->pdo->sql_check_input(array('string', $openId));
|
|
|
|
|
|
- $sql = "select * from " . $this->table_fullname . " where common_guest_wxopenid = $openId limit 1";
|
|
|
+ $sql = "select * from " . $this->table_fullname . " where reader_wxopenid = $openId limit 1";
|
|
|
|
|
|
$rs = $this->pdo->sqlQuery($sql);
|
|
|
$r = array();
|
|
|
@@ -99,32 +90,15 @@ class Table_common_guest extends Table
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function generateNewCode($id)
|
|
|
- {
|
|
|
- $id = $this->pdo->sql_check_input(array('number', $id));
|
|
|
-
|
|
|
- //$sql = "select count(*) as c from " . $this->table_fullname . " where (common_guest_id < $id) and (common_guest_status = 1 or common_guest_status = 0)";
|
|
|
- $sql = "select max(common_guest_code) as c from " . $this->table_fullname;
|
|
|
- $rs = $this->pdo->sqlQuery($sql);
|
|
|
- $count = $rs[0]['c'];
|
|
|
- return sprintf('%04s', $count + 1);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public function add($attr)
|
|
|
{
|
|
|
$param = array(
|
|
|
- //'common_guest_code' => array('string', $attr['code']),
|
|
|
- 'common_guest_phone' => array('string', $attr['phone']),
|
|
|
- 'common_guest_wxopenid' => array('string', $attr['wxopenid']),
|
|
|
- 'common_guest_name' => array('string', $attr['name']),
|
|
|
- 'common_guest_sex' => array('number', $attr['sex']),
|
|
|
- 'common_guest_province' => array('number', $attr['province']),
|
|
|
- 'common_guest_city' => array('number', $attr['city']),
|
|
|
- 'common_guest_detailaddress' => array('string', $attr['detailaddress']),
|
|
|
- 'common_guest_hangye_id' => array('number', $attr['hangye_id']),
|
|
|
- 'common_guest_addtime' => array('number', time()),
|
|
|
- 'common_guest_count' => array('number', 0),
|
|
|
+ 'reader_phone' => array('string', $attr['phone']),
|
|
|
+ 'reader_wxopenid' => array('string', $attr['wxopenid']),
|
|
|
+ 'reader_name' => array('string', $attr['name']),
|
|
|
+ 'reader_sex' => array('number', $attr['sex']),
|
|
|
+ 'reader_addtime' => array('number', time()),
|
|
|
+ 'reader_count' => array('number', 0),
|
|
|
);
|
|
|
|
|
|
return $this->pdo->sqlinsert($this->table_fullname, $param);
|
|
|
@@ -137,7 +111,7 @@ class Table_common_guest extends Table
|
|
|
);
|
|
|
|
|
|
$where = array(
|
|
|
- 'common_guest_id' => array('number', $id)
|
|
|
+ 'reader_id' => array('number', $id)
|
|
|
);
|
|
|
|
|
|
return $this->pdo->sqlupdate($this->table_fullname, $param, $where);
|
|
|
@@ -158,9 +132,7 @@ class Table_common_guest extends Table
|
|
|
|
|
|
if ($count == 0) {//列表
|
|
|
|
|
|
- $sql = "select aa.*, bb.hangye_name as hangye_name from " . $this->table_fullname ." as aa "
|
|
|
- ." left join kano_hangye as bb on aa.common_guest_hangye_id=bb.hangye_id "
|
|
|
- ." $where order by common_guest_addtime desc, common_guest_id desc";
|
|
|
+ $sql = "select * from " . $this->table_fullname . " $where order by reader_addtime desc, reader_id desc";
|
|
|
|
|
|
if ($page > 0) {//分页
|
|
|
$startrow = ($page - 1) * $pagesize;
|