* 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]
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;
}
$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 );
}