This commit is contained in:
wanyongkang
2020-10-23 16:48:49 +08:00
parent 1a58344e46
commit fe0f0a63b3
11 changed files with 374 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
/*
* @Author: your name
* @Date: 2020-09-30 17:32:46
* @LastEditTime: 2020-10-14 20:40:36
* @LastEditTime: 2020-10-23 16:23:12
* @LastEditors: kangkang
* @Description: In User Settings Edit
* @FilePath: /phptest/fastphp/base/Model.php
@@ -61,6 +61,15 @@ class Model extends Sql
{
return $this->field($fields)->where($where)->limit('1')->fetch();
}
/**
* @description: 获取最新一条数据
* @param {*}
* @return {*}
*/
public function getNewOne($fields = '*'){
return $this->field($fields)->order('id desc')->limit(1)->fetch();
}
/**
* @description: 更新一条数据
* @param {type}

View File

@@ -40,16 +40,24 @@ class Sql
if ($flag) {
$flag = false;
if (is_array($value)) {
$this->filter .= ' `' . $key . '` ' . $value[0] . ' :' . $key;
$this->param[$key] = $value[1];
if($value[0] == 'in'){
$this->filter .= ' `' . $key . '` ' . $value[0] . '('.implode(',',$value[1]).')';
} else {
$this->filter .= ' `' . $key . '` ' . $value[0] . ' :' . $key;
$this->param[$key] = $value[1];
}
} else {
$this->filter .= ' `' . $key . '` = :' . $key;
$this->param[$key] = $value;
}
} else {
if (is_array($value)) {
$this->filter .= ' AND `' . $key . '` ' . $value[0] . ' :' . $key;
$this->param[$key] = $value[1];
if($value[0] == 'in'){
$this->filter .= ' AND `' . $key . '` ' . $value[0] . '('.implode(',',$value[1]).')';
} else {
$this->filter .= ' AND `' . $key . '` ' . $value[0] . ' :' . $key;
$this->param[$key] = $value[1];
}
} else {
$this->filter .= ' AND `' . $key . '` = :' . $key;
$this->param[$key] = $value;
@@ -83,7 +91,7 @@ class Sql
*/
public function group($group = [])
{
if ($order) {
if ($group) {
$this->filter .= ' GROUP BY ';
$this->filter .= ' ' . implode(' ,', $group) . ' ';
}