PHP中的数组功能非常强大,在很多的PHP框架中将也将SQL中的WHERE语句作为数组来传入,下面是其中的一种解析方式 public static function where($where){if (is_string($where) && $where){return preg_match("//s*where/s+/i", $where) ? $where : ' WHERE '.$where;}elseif (is_array($where)){$sql = '1';foreach ($where as $key => $value){if (is_array($value)){$sql .= " AND $key IN ('".implode('/',/'', $value)."')";}else {if (strncmp('<', $value, 1) == 0){$sql .= " AND $key < '".substr($value, 1)."'";}elseif (strncmp('>', $value, 1) == 0){$sql .= " AND $key > '".substr($value, 1)."'";}elseif (strncmp('>=', $value, 2) == 0){$sql .= " AND $key >= '".substr($value, 2)."'";}elseif (strncmp('<=', $value, 2) == 0){$sql .= " AND $key <= '".substr($value, 2)."'";}elseif (strncmp('!', $value, 1) == 0){$sql .= " AND $key != '".substr($value, 1)."'";}else {$sql .= " AND $key = '$value'";}}}return self::where($sql);}else {return '1';}} 调用: $tmp = (array)$this->sf->getService('Book')->getList(array('ID'=>$ids, 'IsDelete' => 0, 'IsOnSale' => 1));