replace fixes:
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 7 Sep 2004 08:37:50 +0000 (08:37 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 7 Sep 2004 08:37:50 +0000 (08:37 +0000)
* use array_keys() instead of array_flip() to get the keys, since the latter fails with NULL data
* where there is a single-column unique index, don't forget the initial paren since it's going to get closed [fix for <math> rendering]

includes/DatabasePostgreSQL.php

index 4f437fe..b3e74ec 100644 (file)
@@ -289,12 +289,12 @@ class DatabasePgsql extends Database {
                                foreach ( $uniqueIndexes as $index ) {
                                        if ( $first ) {
                                                $first = false;
+                                               $sql .= "(";
                                        } else {
                                                $sql .= ') OR (';
                                        }
                                        if ( is_array( $index ) ) {
                                                $first2 = true;
-                                               $sql .= "(";
                                                foreach ( $index as $col ) {
                                                        if ( $first2 ) { 
                                                                $first2 = false;
@@ -303,16 +303,16 @@ class DatabasePgsql extends Database {
                                                        }
                                                        $sql .= $col.'=' . $this->addQuotes( $row[$col] );
                                                }
-                               } else {
+                                       } else {
                                                $sql .= $index.'=' . $this->addQuotes( $row[$index] );
-                               }
+                                       }
                                }
                                $sql .= ')';
                                $this->query( $sql, $fname );
                        }
 
                        # Now insert the row
-                       $sql = "INSERT INTO $table (" . $this->makeList( array_flip( $row ), LIST_NAMES ) .') VALUES (' .
+                       $sql = "INSERT INTO $table (" . $this->makeList( array_keys( $row ), LIST_NAMES ) .') VALUES (' .
                                $this->makeList( $row, LIST_COMMA ) . ')';
                        $this->query( $sql, $fname );
                }