王总上门按摩后台代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
shangmenanmo/app/BaseModel.php

80 lines
1.7 KiB

<?php
namespace app;
use think\Model;
use think\facade\Db;
class BaseModel extends Model {
//设置数据库表名称
protected $name = 'longbing';
protected $type = [
'create_time' => 'int',
'update_time' => 'int',
'delete_time' => 'int',
'deleted' => 'int'
];
//获取详情
public function getRow($filter)
{
$filter['deleted'] = 0;
$result = $this
->where($filter)
->find();
if(!empty($result)) $result = $result->toArray();
return $result;
}
//获取列表
public function listRow($filter)
{
$filter['deleted'] = 0;
$result = $this
->where($filter)
->select();
if(!empty($result)) $result = $result->toArray();
return $result;
}
//创建
public function createRow($data)
{
if(!empty($data['create_time'])){
$data['create_time'] = time();
}
return $this->save($data);
}
//批量创建
public function createRows($datas)
{
return $this->saveAll($datas);
}
public function upsave($filter ,$data)
{
$data['update_time'] = time();
$result = $this->where($filter)->update($data);
if(empty($result)) return false;
return true;
}
//更新
public function updateRow($filter ,$data)
{
$filter['deleted'] = 0;
$data['update_time'] = time();
$result = $this->where($filter)->update($data);
if(empty($result)) return false;
return true;
}
//删除
public function deleteRow($filter)
{
$filter['deleted'] = 0;
$result = $this->updateRow($filter ,['delete_time' => time() ,'deleted' => 1]);
if(empty($result)) return false;
return true;
}
//真删除
public function destroyRow($filter)
{
$result = $this->where($filter)->delete();
if(empty($result)) return false;
return true;
}
}