From 631eda22a1e873ea7c91c58d68df072ff66d2f54 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 7 Sep 2004 08:37:50 +0000 Subject: [PATCH] replace fixes: * 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 rendering] --- includes/DatabasePostgreSQL.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/DatabasePostgreSQL.php b/includes/DatabasePostgreSQL.php index 4f437fea95..b3e74ec2f6 100644 --- a/includes/DatabasePostgreSQL.php +++ b/includes/DatabasePostgreSQL.php @@ -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 ); } -- 2.20.1