From: Tim Starling Date: Sun, 12 Feb 2006 02:20:32 +0000 (+0000) Subject: options to insertSelect(), indenting X-Git-Tag: 1.6.0~342 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=35438cbe914abce800c68371bd4be3928e132446;p=lhc%2Fweb%2Fwiklou.git options to insertSelect(), indenting --- diff --git a/includes/Database.php b/includes/Database.php index b7b0a16d76..1dfe194cf6 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1327,15 +1327,20 @@ class Database { * $conds may be "*" to copy the whole table * srcTable may be an array of tables. */ - function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect' ) { + function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect', + $options = array() ) + { $destTable = $this->tableName( $destTable ); - if( is_array( $srcTable ) ) { - $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) ); - } else { + if ( is_array( $options ) ) { + $options = implode( ' ', $options ); + } + if( is_array( $srcTable ) ) { + $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) ); + } else { $srcTable = $this->tableName( $srcTable ); } - $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' . - ' SELECT ' . implode( ',', $varMap ) . + $sql = "INSERT $options INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' . + ' SELECT ' . implode( ',', $varMap ) . " FROM $srcTable"; if ( $conds != '*' ) { $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );