收支核对修改
This commit is contained in:
@@ -28,11 +28,12 @@ class Sql
|
||||
*/
|
||||
public function where($where)
|
||||
{
|
||||
$this->param = [];
|
||||
$this->filter = '';
|
||||
$this->filter .= '';
|
||||
if ($where) {
|
||||
if(!strpos('$this->filter','WHERE') !== false){
|
||||
if(!strpos($this->filter,'WHERE') !== false){
|
||||
$this->filter .= ' WHERE ';
|
||||
} else {
|
||||
$this->filter .= ' AND ';
|
||||
}
|
||||
if (is_string($where)) {
|
||||
$this->filter .= $where;
|
||||
@@ -45,8 +46,9 @@ class Sql
|
||||
if($value[0] == 'in'){
|
||||
$this->filter .= ' `' . $key . '` ' . $value[0] . '('.implode(',',$value[1]).')';
|
||||
} else {
|
||||
$this->filter .= ' `' . $key . '` ' . $value[0] . ' :' . $key;
|
||||
$this->param[$key] = $value[1];
|
||||
$param_key = $this->paramIsExit($key,$this->param);
|
||||
$this->filter .= ' `' . $key . '` ' . $value[0] . ' :' . $param_key;
|
||||
$this->param[$param_key] = $value[1];
|
||||
}
|
||||
} else {
|
||||
$this->filter .= ' `' . $key . '` = :' . $key;
|
||||
@@ -57,8 +59,9 @@ class Sql
|
||||
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];
|
||||
$param_key = $this->paramIsExit($key,$this->param);
|
||||
$this->filter .= ' AND `' . $key . '` ' . $value[0] . ' :' . $param_key;
|
||||
$this->param[$param_key] = $value[1];
|
||||
}
|
||||
} else {
|
||||
$this->filter .= ' AND `' . $key . '` = :' . $key;
|
||||
@@ -71,73 +74,15 @@ class Sql
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询条件 处理复杂查询条件
|
||||
* @param {*} [ 'day_time' => [ ['>' , val1], ['<' , val2] ] ]
|
||||
* @return {*}
|
||||
*/
|
||||
public function wheres($where)
|
||||
{
|
||||
$this->param = [];
|
||||
$this->filter = '';
|
||||
if ($where) {
|
||||
|
||||
if(!strpos('$this->filter','WHERE') !== false){
|
||||
$this->filter .= ' WHERE ';
|
||||
}
|
||||
if (is_string($where)) {
|
||||
$this->filter .= ' WHERE ' . $where;
|
||||
} else {
|
||||
$flag = true;
|
||||
foreach ($where as $key => $value) {
|
||||
if ($flag) {
|
||||
$flag = false;
|
||||
if (is_array($value)) {
|
||||
$flag2 = true;
|
||||
foreach($value as $k => $v) {
|
||||
if($flag2){
|
||||
$flag2 = false;
|
||||
if($v[0] == 'in'){
|
||||
$this->filter .= ' `' . $key . '` ' . $v[0] . '('.implode(',',$v[1]).')';
|
||||
} else {
|
||||
$this->filter .= ' `' . $key . '` ' . $v[0] . ' :' . $key.$k;
|
||||
$this->param[$key.$k] = $v[1];
|
||||
}
|
||||
} else {
|
||||
if($v[0] == 'in'){
|
||||
$this->filter .= ' AND `' . $key . '` ' . $v[0] . '('.implode(',',$v[1]).')';
|
||||
} else {
|
||||
$this->filter .= ' AND `' . $key . '` ' . $v[0] . ' :' . $key.$k;
|
||||
$this->param[$key.$k] = $v[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->filter .= ' `' . $key . '` = :' . $key;
|
||||
$this->param[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
if (is_array($value)) {
|
||||
foreach($value as $k => $v) {
|
||||
if($v[0] == 'in'){
|
||||
$this->filter .= ' AND `' . $key . '` ' . $v[0] . '('.implode(',',$v[1]).')';
|
||||
} else {
|
||||
$this->filter .= ' AND `' . $key . '` ' . $v[0] . ' :' . $key.$k;
|
||||
$this->param[$key.$k] = $v[1];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->filter .= ' AND `' . $key . '` = :' . $key;
|
||||
$this->param[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function paramIsExit($key,$param){
|
||||
if(!isset($param[$key])){
|
||||
return $key;
|
||||
} else {
|
||||
$key .= $key;
|
||||
return $this->paramIsExit($key,$param);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼装排序条件
|
||||
* @param array $order 排序条件
|
||||
@@ -202,6 +147,7 @@ class Sql
|
||||
$this->filter = '';
|
||||
$sth = Db::pdo()->prepare($sql);
|
||||
$sth = $this->formatParam($sth, $this->param);
|
||||
$this->param = [];
|
||||
$sth->execute();
|
||||
|
||||
return $sth->fetchAll();
|
||||
@@ -217,6 +163,7 @@ class Sql
|
||||
$this->filter = '';
|
||||
$sth = Db::pdo()->prepare($sql);
|
||||
$sth = $this->formatParam($sth, $this->param);
|
||||
$this->param = [];
|
||||
$sth->execute();
|
||||
|
||||
return $sth->fetch();
|
||||
@@ -233,6 +180,7 @@ class Sql
|
||||
$this->filter = '';
|
||||
$sth = Db::pdo()->prepare($sql);
|
||||
$sth = $this->formatParam($sth, $this->param);
|
||||
$this->param = [];
|
||||
$sth->execute();
|
||||
|
||||
return $sth->rowCount();
|
||||
@@ -279,6 +227,7 @@ class Sql
|
||||
$sth = Db::pdo()->prepare($sql);
|
||||
$sth = $this->formatParam($sth, $data);
|
||||
$sth = $this->formatParam($sth, $this->param);
|
||||
$this->param = [];
|
||||
$sth->execute();
|
||||
|
||||
return $sth->rowCount();
|
||||
|
||||
Reference in New Issue
Block a user