$useIndexes = ( isset( $options['USE INDEX'] ) && is_array( $options['USE INDEX'] ) )
? $options['USE INDEX']
: [];
- $ignoreIndexes = ( isset( $options['IGNORE INDEX'] ) && is_array( $options['IGNORE INDEX'] ) )
+ $ignoreIndexes = (
+ isset( $options['IGNORE INDEX'] ) &&
+ is_array( $options['IGNORE INDEX'] )
+ )
? $options['IGNORE INDEX']
: [];
if ( is_array( $table ) ) {
$from = ' FROM ' .
- $this->tableNamesWithIndexClauseOrJOIN( $table, $useIndexes, $ignoreIndexes, $join_conds );
+ $this->tableNamesWithIndexClauseOrJOIN(
+ $table, $useIndexes, $ignoreIndexes, $join_conds );
} elseif ( $table != '' ) {
if ( $table[0] == ' ' ) {
$from = ' FROM ' . $table;
} else {
$from = ' FROM ' .
- $this->tableNamesWithIndexClauseOrJOIN( [ $table ], $useIndexes, $ignoreIndexes, [] );
+ $this->tableNamesWithIndexClauseOrJOIN(
+ [ $table ], $useIndexes, $ignoreIndexes, [] );
}
} else {
$from = '';
if ( is_array( $conds ) ) {
$conds = $this->makeList( $conds, self::LIST_AND );
}
- $sql = "SELECT $startOpts $vars $from $useIndex $ignoreIndex WHERE $conds $preLimitTail";
+ $sql = "SELECT $startOpts $vars $from $useIndex $ignoreIndex " .
+ "WHERE $conds $preLimitTail";
} else {
$sql = "SELECT $startOpts $vars $from $useIndex $ignoreIndex $preLimitTail";
}
}
}
if ( isset( $ignore_index[$alias] ) ) { // has IGNORE INDEX?
- $ignore = $this->ignoreIndexClause( implode( ',', (array)$ignore_index[$alias] ) );
+ $ignore = $this->ignoreIndexClause(
+ implode( ',', (array)$ignore_index[$alias] ) );
if ( $ignore != '' ) {
$tableClause .= ' ' . $ignore;
}
$srcTable = $this->tableName( $srcTable );
}
- $sql = "INSERT $insertOptions INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
+ $sql = "INSERT $insertOptions" .
+ " INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
" SELECT $startOpts " . implode( ',', $varMap ) .
" FROM $srcTable $useIndex $ignoreIndex ";
}
} else {
if ( !$this->mTrxLevel ) {
- $this->queryLogger->error( "$fname: No transaction to commit, something got out of sync." );
+ $this->queryLogger->error(
+ "$fname: No transaction to commit, something got out of sync." );
return; // nothing to do
} elseif ( $this->mTrxAutomatic ) {
// @TODO: make this an exception at some point
* @throws Exception
*/
public function sourceFile(
- $filename, $lineCallback = false, $resultCallback = false, $fname = false, $inputCallback = false
+ $filename,
+ $lineCallback = false,
+ $resultCallback = false,
+ $fname = false,
+ $inputCallback = false
) {
MediaWiki\suppressWarnings();
$fp = fopen( $filename, 'r' );
}
try {
- $error = $this->sourceStream( $fp, $lineCallback, $resultCallback, $fname, $inputCallback );
+ $error = $this->sourceStream(
+ $fp, $lineCallback, $resultCallback, $fname, $inputCallback );
} catch ( Exception $e ) {
fclose( $fp );
throw $e;
* @param bool|callable $inputCallback Optional function called for each complete query sent
* @return bool|string
*/
- public function sourceStream( $fp, $lineCallback = false, $resultCallback = false,
- $fname = __METHOD__, $inputCallback = false
+ public function sourceStream(
+ $fp,
+ $lineCallback = false,
+ $resultCallback = false,
+ $fname = __METHOD__,
+ $inputCallback = false
) {
$cmd = '';
if ( $done || feof( $fp ) ) {
$cmd = $this->replaceVars( $cmd );
- if ( ( $inputCallback && call_user_func( $inputCallback, $cmd ) ) || !$inputCallback ) {
+ if ( !$inputCallback || call_user_func( $inputCallback, $cmd ) ) {
$res = $this->query( $cmd, $fname );
if ( $resultCallback ) {
public function streamStatementEnd( &$sql, &$newLine ) {
if ( $this->delimiter ) {
$prev = $newLine;
- $newLine = preg_replace( '/' . preg_quote( $this->delimiter, '/' ) . '$/', '', $newLine );
+ $newLine = preg_replace(
+ '/' . preg_quote( $this->delimiter, '/' ) . '$/', '', $newLine );
if ( $newLine != $prev ) {
return true;
}