From f6f431971d16f4acd0dd4eb1324a256358b9dacc Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Wed, 1 Sep 2004 12:27:57 +0000 Subject: [PATCH] treat every array as an array, not only with option IGNORE, IGNORE single-row inserts as well, if specified. --- includes/DatabasePostgreSQL.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/includes/DatabasePostgreSQL.php b/includes/DatabasePostgreSQL.php index f98814f816..b7665f4093 100644 --- a/includes/DatabasePostgreSQL.php +++ b/includes/DatabasePostgreSQL.php @@ -172,21 +172,27 @@ class DatabasePgsql extends Database { # We have a go at faking one of them # TODO: DELAYED, LOW_PRIORITY - # IGNORE is performed using single-row inserts, ignoring errors in each - if ( in_array( 'IGNORE', $options ) ) { - # FIXME: need some way to distiguish between key collision and other types of error + if ( !is_array($options)) + $options = array($options); + + if ( in_array( 'IGNORE', $options ) ) $oldIgnore = $this->ignoreErrors( true ); - if ( !is_array( reset( $a ) ) ) { - $a = array( $a ); - } - foreach ( $a as $row ) { - parent::insertArray( $table, $row, $fname, array() ); - } - $this->ignoreErrors( $oldIgnore ); - $retVal = true; - } else { - $retVal = parent::insertArray( $table, $a, $fname, array() ); + + # IGNORE is performed using single-row inserts, ignoring errors in each + # FIXME: need some way to distiguish between key collision and other types of error + $oldIgnore = $this->ignoreErrors( true ); + if ( !is_array( reset( $a ) ) ) { + $a = array( $a ); + } + foreach ( $a as $row ) { + parent::insertArray( $table, $row, $fname, array() ); } + $this->ignoreErrors( $oldIgnore ); + $retVal = true; + + if ( in_array( 'IGNORE', $options ) ) + $this->ignoreErrors( $oldIgnore ); + return $retVal; } -- 2.20.1