作者 root

gx

... ... @@ -18,16 +18,26 @@ class Base extends Model
public function lists($map, $p, $row, $order = 'id', $fields = ['*']){
//TODO::where(['id'=>'','name'=>''])
$lists = $this->select($fields)->where($map)->forPage($p,$row)->orderBy($order)->get();
if (!empty($lists)) {
if ($lists->isEmpty() === false) {
$lists = $lists->toArray();
$this->allCount = DB::table($this->table)->where($map)->count();
$this->allCount = $this->where($map)->count();
}
return $lists;
}
/**
* @param $map
* @param $order
* @param $fields
* @name :无分页列表
* @return mixed
* @author :liyuhang
* @method
*/
public function list($map,$order = 'id',$fields = ['*']){
$lists = $this->select($fields)->where($map)->orderBy($order)->get();
if (!empty($lists)) {
if ($lists->isEmpty() === false) {
$lists = $lists->toArray();
}
return $lists;
... ... @@ -41,10 +51,14 @@ class Base extends Model
*/
public function read($condition,$files = ['*'])
{
$info = $this->select($files)->where($condition)->first()->toArray();
$info = $this->select($files)->where($condition)->first();
if (!empty($info)) {
$info = $info->toArray();
}
return $info;
}
/**
* @name :新增
* @return void
... ... @@ -52,8 +66,8 @@ class Base extends Model
* @method post
*/
public function add($data){
$data['created_at'] = date('Y-m-d H:i:s',time());
$data['updated_at'] = date('Y-m-d H:i:s',time());
// $data['created_at'] = date('Y-m-d H:i:s',time());
// $data['updated_at'] = date('Y-m-d H:i:s',time());
return $this->insert($data);
}
... ... @@ -67,7 +81,7 @@ class Base extends Model
if(isset($data['id']) && !empty($data['id'])){
unset($data['id']);
}
$data['updated_at'] = date('Y-m-d H:i:s',time());
// $data['updated_at'] = date('Y-m-d H:i:s',time());
return $this->where($condition)->update($data);
}
... ...