1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 15:47:00 +02:00

Respect where in COUNT(*) link

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1441 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2010-04-15 12:42:31 +00:00
parent 6a53e5542d
commit 16290b0929
2 changed files with 17 additions and 22 deletions

View File

@@ -159,32 +159,17 @@ function unique_array($row, $indexes) {
return $return;
}
/** Get query string for unique identifier of a row
* @param array
* @param array result of indexes()
* @return string
*/
function unique_idf($row, $indexes) {
$return = "";
foreach (unique_array($row, $indexes) as $key => $val) {
$return .= "&" . (isset($val) ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key));
}
return $return;
}
/** Create SQL condition from parsed query string
* @param array parsed query string
* @return string
*/
function where($where) {
$return = array();
foreach ((array) $where["where"] as $key => $val) {
$key = bracket_escape($key, "back");
$return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . (ereg('\\.', $val) ? " LIKE " . exact_value(addcslashes($val, "%_")) : " = " . exact_value($val)); // LIKE because of floats, but slow with ints //! enum and set, columns looking like functions
}
foreach ((array) $where["null"] as $key) {
$key = bracket_escape($key, "back");
$return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . " IS NULL";
foreach (array("where", "null") as $type) {
foreach ((array) $where[$type] as $key => $val) {
$key = bracket_escape($key, "back");
$return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . ($type == "null" ? " IS NULL" : (ereg('\\.', $val) ? " LIKE " . exact_value(addcslashes($val, "%_")) : " = " . exact_value($val))); // LIKE because of floats, but slow with ints //! enum and set, columns looking like functions
}
}
return implode(" AND ", $return);
}