|
@@ -38,6 +38,7 @@ trait SQL
|
|
);
|
|
);
|
|
private $condition = ['eq', 'neq', 'gt', 'lt', 'gte', 'lte', 'in', 'between', 'like', 'llike', 'rlike'];
|
|
private $condition = ['eq', 'neq', 'gt', 'lt', 'gte', 'lte', 'in', 'between', 'like', 'llike', 'rlike'];
|
|
private $conditionFormatter = [
|
|
private $conditionFormatter = [
|
|
|
|
+ 'null' => '%s IS NULL',
|
|
'eq' => "%s = '%s'",
|
|
'eq' => "%s = '%s'",
|
|
'neq' => "%s != '%s'",
|
|
'neq' => "%s != '%s'",
|
|
'gt' => "%s > '%s'",
|
|
'gt' => "%s > '%s'",
|
|
@@ -308,6 +309,9 @@ trait SQL
|
|
$this->handleError(!$field, '字段名不能为空');
|
|
$this->handleError(!$field, '字段名不能为空');
|
|
$tmp = explode(':', $field);
|
|
$tmp = explode(':', $field);
|
|
if(count($tmp) == 1) {
|
|
if(count($tmp) == 1) {
|
|
|
|
+ if(is_null($val)) {
|
|
|
|
+ return sprintf($this->conditionFormatter['null'], $this->handleFieldAlias($field));
|
|
|
|
+ }
|
|
return sprintf($this->conditionFormatter['eq'], $this->handleFieldAlias($field), $this->setQuote($val));
|
|
return sprintf($this->conditionFormatter['eq'], $this->handleFieldAlias($field), $this->setQuote($val));
|
|
}
|
|
}
|
|
$cond = array_pop($tmp);
|
|
$cond = array_pop($tmp);
|
|
@@ -345,7 +349,6 @@ trait SQL
|
|
*/
|
|
*/
|
|
private function handleSubWhere($where) {
|
|
private function handleSubWhere($where) {
|
|
$arr = [];
|
|
$arr = [];
|
|
-
|
|
|
|
$count = count($where);
|
|
$count = count($where);
|
|
// 多维数组处理
|
|
// 多维数组处理
|
|
if(count($where, 1) > $count) {
|
|
if(count($where, 1) > $count) {
|
|
@@ -513,7 +516,9 @@ trait SQL
|
|
final public function order($order){
|
|
final public function order($order){
|
|
$this->handleError(!is_array($order) && !is_string($order), 'order 参数必须为字符串或数组, 获取到的是'. gettype($order));
|
|
$this->handleError(!is_array($order) && !is_string($order), 'order 参数必须为字符串或数组, 获取到的是'. gettype($order));
|
|
|
|
|
|
- if((is_array($order) && count($order) == 0) || preg_match('/(COUNT|SUM)\((.*)\)/', $this->fields)) {
|
|
|
|
|
|
+ //if((is_array($order) && count($order) == 0) || preg_match('/(COUNT|SUM)\((.*)\)/', $this->fields)) {
|
|
|
|
+ // 去掉限制
|
|
|
|
+ if((is_array($order) && count($order) == 0)) {
|
|
return $this;
|
|
return $this;
|
|
}
|
|
}
|
|
|
|
|