12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\user\model;
- use think\Model;
- class Mail extends Model{
-
- protected $autoWriteTimestamp = 'datetime'; // 开启自动写入时间戳字段
- protected $createTime = 'create_time'; // 创建时间
- protected $updateTime = ''; // 每次更新时间
-
- public function initialize(){
- parent::initialize();
- }
-
- /**
- * 获取数据信息
- * @param int $page 页码
- * @param array $where 查询条件
- */
- public function getInfo($page = 0, $where = array()){
- return $this->db()
- ->where($where)
- ->page($page, config('paginate.list_rows'))
- ->select();
- }
-
- /**
- * 获取分页信息
- * @param array $where 查询条件
- */
- public function getPage($where = array()){
- $query = getPaginatiorQuery();
- $total = $this->db()->where($where)->count();
- // 查询条件
- $config = ['query'=>$query];
- $paginate = $this->db()->where($where)->paginate(config('paginate.list_rows'), $total, $config);
-
- return $paginate->render();
- }
-
- /**
- * 根据id找到对象
- * @param int $id
- */
- public function getMailById($id){
- return $this->db()->where(['id'=>$id])->find();
- }
-
- /**
- * 添加和更新的方法
- */
- public function addAndSave(){
- $data = request()->post();
- return $this->allowField(true)->isUpdate(isset($data['id']) && $data['id']?true:false)->save($data);
- }
-
- }
|