修改phplib/XWork/Db.php文件中buildConds()方法,原:
private function buildConds($arrConds, &$conds, &$bind) {
if (!$arrConds) {
return;
}
if (is_array($arrConds)) {
foreach ($arrConds as $name => $value) {
if (is_int($name)) {
$conds .= " AND $value ";
} else {
$conds .= " AND $name ?";
$bind[] = $value;
}
}
} else {
$conds = $arrConds;
}
}
修改后:
private function buildConds($arrConds, &$conds, &$bind) {
if (!$arrConds) {
return;
}
if (is_array($arrConds)) {
foreach ($arrConds as $name => $value) {
if (is_int($name)) {
$conds .= " AND $value ";
} else {
if(strpos($name,'OR ') !== false) {
$conds .= " $name ?";
} else {
$conds .= " AND $name ?";
}
$bind[] = $value;
}
}
} else {
$conds = $arrConds;
}
}
使用:
$cond['OR admin_id='] = 1;