* Make it possible to use the Database.php class to make queries like
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Thu, 14 Jul 2005 17:00:54 +0000 (17:00 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Thu, 14 Jul 2005 17:00:54 +0000 (17:00 +0000)
  SELECT * FROM user WHERE user_id = user_name; (note the lack of quotes),
  use array('user_id' => array(false, 'user_name')) to do this.

includes/Database.php

index 98bf45e..c4d90ca 100644 (file)
@@ -967,13 +967,15 @@ class Database {
                        }
                        if ( $mode == LIST_AND && is_numeric( $field ) ) {
                                $list .= "($value)";
-                       } elseif ( $mode == LIST_AND && is_array ($value) ) {
+                       } elseif ( $mode == LIST_AND && is_array ($value) && $value[0] !== false ) {
                                $list .= $field." IN (".$this->makeList($value).") ";
+                       } elseif ( $mode == LIST_AND && is_array ($value) && $value[0] === false ) {
+                               $list .= "$field = {$value[1]}";
                        } else {
                                if ( $mode == LIST_AND || $mode == LIST_SET ) {
                                        $list .= $field.'=';
                                }
-                               $list .= ($mode==LIST_NAMES?$value:$this->addQuotes( $value ));
+                               $list .= ($mode == LIST_NAMES ? $value : $this->addQuotes( $value ));
                        }
                }
                return $list;