This commit is contained in:
wanyongkang
2020-10-13 09:38:55 +08:00
parent 517b026891
commit 7d7d8f09ad
5 changed files with 245 additions and 102 deletions

View File

@@ -1,5 +1,12 @@
<?php
/*
* @Author: your name
* @Date: 2020-09-30 17:32:46
* @LastEditTime: 2020-10-12 11:16:10
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /phptest/fastphp/base/Model.php
*/
namespace fastphp\base;
@@ -12,12 +19,12 @@ class Model extends Sql
public function __construct()
{
//获取数据库表名
if(!$this->table){
if (!$this->table) {
//获取模型类名称
$this->model = get_class($this);
//删除模型名最后的model
$this->model = substr($this->model,0,-5);
$this->model = substr($this->model, 0, -5);
//数据库表名与类名一致
$this->table = strtolower($this->model);
@@ -26,10 +33,11 @@ class Model extends Sql
/**
* 获取总数目
*
*
*/
public function getCount(){
return $this->field('count(1) as count')->fetch();
public function getCount($where = [])
{
return $this->field('count(1) as count')->where($where)->fetch();
}
/**
@@ -39,9 +47,10 @@ class Model extends Sql
* @param $limit = '100' 限制查询100条
* $limit = '2,100' 查询第二页 100条数据
*/
public function getListPage($fields = '*',$order = 'id desc', $page = '50')
public function getListPage($where = [],$fields = '*', $order = 'id desc', $limit = '50')
{
return $this->field($fields)->order($order)->limit($page)->fetchAll();
return $this->field($fields)->where($where)->order($order)->limit($limit)->fetchAll();
}
}
}