where($where); } if(empty($order)){ $order['id']='desc'; } $res = $this->field($field)->page($page)->limit($pageSize)->order($order)->select(); return $res; } /** * @param type $where * @return type */ public function x_count($where) { $res = $this->where($where)->count(); return $res; } /** * @author 545 16.4.14 插入 * @param type $data 要插入的字段 * @return type */ public function x_set_add($data) { if ($this->create($data)) { $res = $this->add(); // 写入数据到数据库 // 如果主键是自动增长型 成功后返回值就是最新插入的值 return $res; } } /** * @author 545 16.4.14 更新 * @param type $data * @param type $where */ public function x_save($data, $where) { if (!empty($where)) { $this->where($where); } $res = $this->save($data); return $res; } /** * @param type $where 更新条件 * @param type $field 查询字段 * @return type */ public function x_get_one($where, $field = '*',$order='') { $res = $this->where($where)->field($field)->order($order)->find(); return $res; } /** * @param type $where 删除条件 * @return type */ public function x_del($where) { $res = $this->where($where)->delete(); return $res; } /** * @author 545 16.4.14 分页 * @param type $count 统计数值 * @param type $pageSize 行数 * @return type */ public function x_show($count, $pageSize,$params = []) { $Page = new Page($count, $pageSize,$params); $pager = $Page->show(); return $pager; } /** * @param type $where 条件 * @param type $sum 求和字段 * @return type */ public function x_sum($where,$sum) { $res = $this->where($where)->sum($sum); return $res; } }