first commit
This commit is contained in:
48
pgserver/application/model/Base.php
Normal file
48
pgserver/application/model/Base.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Base extends Model {
|
||||
|
||||
// protected $resultSetType = 'collection';
|
||||
|
||||
/**
|
||||
* @author 涂润
|
||||
* 查询多条信息
|
||||
*/
|
||||
public static function getAll($where, $field = '', $order = '', $limit = '') {
|
||||
return self::where($where)->field($field)->order($order)->limit($limit)->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 涂润
|
||||
* 获取单条信息
|
||||
*/
|
||||
public static function getOne($where, $field, $order = []) {
|
||||
return self::where($where)->field($field)->order($order)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 涂润
|
||||
* 获取条数
|
||||
* @param $where
|
||||
* @return int|string
|
||||
*/
|
||||
public static function getCount($where, $lock = false) {
|
||||
return self::where($where)->lock($lock)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 涂润
|
||||
* 添加/主键更新单条记录
|
||||
* @param $data
|
||||
* @return false|int
|
||||
*/
|
||||
public function add($data) {
|
||||
return $this->save($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user