51 lines
1.1 KiB
PHP
Executable File
51 lines
1.1 KiB
PHP
Executable File
<?php
|
|
namespace app\model;
|
|
|
|
use think\Model;
|
|
|
|
class Base extends Model
|
|
{
|
|
protected $autoWriteTimestamp = false;
|
|
|
|
public const BOOL_TRUE = 1;
|
|
public const BOOL_FALSE = 0;
|
|
|
|
//根据Id列表获取列表
|
|
public static function getListByIds($ids)
|
|
{
|
|
if(count($ids) == 0 || empty($ids)) {
|
|
return [];
|
|
}
|
|
return self::where('id', 'in', $ids)->select()->toArray();
|
|
}
|
|
//根据ID获取单条数据
|
|
public static function getById($id)
|
|
{
|
|
if($id <= 0){
|
|
return [];
|
|
}
|
|
return self::where('id', $id)->findOrEmpty()->toArray();
|
|
}
|
|
|
|
//根据ID更新数据
|
|
public static function updateById($id, $data)
|
|
{
|
|
return self::where('id', $id)->update($data);
|
|
}
|
|
|
|
//根据where条件和排序获取记录
|
|
public static function getListByWhereAndOrder($where, $order, $limit = 1)
|
|
{
|
|
return self::where($where)
|
|
->order($order)
|
|
->limit($limit)
|
|
->select()
|
|
->toArray();
|
|
}
|
|
|
|
// 根据ID查询记录详情
|
|
public static function findInfoById($id)
|
|
{
|
|
return self::where('id', $id)->find();
|
|
}
|
|
} |