insertGetId($data); return $id; } /** * 添加多条的操作 * @param $data * @return int|string */ public function addAllInfo($data){ $id = $this->insertAll($data); return $id; } /** * 更新操作 * @param $where * @param $data * @return $this */ public function upInfo($where,$data){ $bool = $this->where($where)->update($data); return $bool; } /** * 通过条件获取列表 * @param $where * @param $order * @param $limit * @return false|\PDOStatement|string|\think\Collection */ public function getList($where=[],$order="",$limit=50){ $list = $this->where($where); if(!empty($order)){ $list = $list->order($order); } $list = $list->limit($limit)->select(); return $list; } /** * 通过条件获取分页列表 * @param array $where * @param string $order * @param int $page * @param int $pageSize * @return array */ public function getPage($where=[],$order="",$page=1,$pageSize=2){ $data = [ 'count'=> $this->_getPage($where,$order), 'list'=>$this->_getPage($where,$order,$page,$pageSize,'list') ]; return $data; } /** * 针对于分页的基方法 * @param $where * @param $order * @param int $page * @param int $pageSize * @param string $type * @return false|int|\PDOStatement|string|\think\Collection */ private function _getPage($where,$order,$page=1,$pageSize=2,$type='count'){ $list = $this; if($where) { $list = $this->where($where); } if($order){ $list = $this->order($order); } if($type == 'count') { return $list->count(); }else{ if(intval($pageSize) > 100){ $pageSize = 100; } return $list->page(intval($page),intval($pageSize))->select(); } } /** * 根据条件获取一条记录 * @param $where * @return array|false|\PDOStatement|string|Model */ public function getOne($where=[]){ if($where){ $list = $this->where($where)->find(); }else{ $list = $this->find(); } return $list; } }