Skip to content

Commit 8a13000

Browse files
committed
改进where方法用法,支持更复杂的查询
1 parent a7294fb commit 8a13000

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ThinkPHP/Lib/Core/Db.class.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ protected function parseWhere($where) {
423423
}
424424
foreach ($where as $key=>$val){
425425
$whereStr .= '( ';
426+
if(is_numeric($key)){
427+
$key = '_complex';
428+
}
426429
if(0===strpos($key,'_')) {
427430
// 解析特殊条件表达式
428431
$whereStr .= $this->parseThinkWhere($key,$val);

ThinkPHP/Lib/Core/Model.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ protected function _parseOptions($options=array()) {
554554
if(is_scalar($val)) {
555555
$this->_parseType($options['where'],$key);
556556
}
557-
}elseif('_' != substr($key,0,1) && false === strpos($key,'.') && false === strpos($key,'(') && false === strpos($key,'|') && false === strpos($key,'&')){
557+
}elseif(!is_numeric($key) && '_' != substr($key,0,1) && false === strpos($key,'.') && false === strpos($key,'(') && false === strpos($key,'|') && false === strpos($key,'&')){
558558
unset($options['where'][$key]);
559559
}
560560
}

0 commit comments

Comments
 (0)