From: Domas Mituzas Date: Wed, 1 Sep 2004 12:27:57 +0000 (+0000) Subject: treat every array as an array, not only with option IGNORE, X-Git-Tag: 1.5.0alpha1~2185 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=f6f431971d16f4acd0dd4eb1324a256358b9dacc;p=lhc%2Fweb%2Fwiklou.git treat every array as an array, not only with option IGNORE, IGNORE single-row inserts as well, if specified. --- 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; }