/** * 连表Where * @param $conds * @param string $type * @return string */ protected function buildWhere($conds, $type = 'and') { $wheres = []; foreach ($conds as $values) { foreach ($values as $key => $cond) { if ($key == "__and__" || $key == "__or__") { $key = str_replace("_", "", $key); $sCond = $this->buildWhere($cond, $key); if ($sCond) { $wheres[] = $sCond; } } elseif ($key == self::valueKey) { $sCond = $this->DAO->buildWhere($cond, $type); if ($sCond) { $wheres[] = $sCond; } } } } if (!$wheres) { return ''; } elseif (count($wheres) == 1) { return $wheres[0]; } return "(" . join(") {$type} (", $wheres) . ")"; }