}
}
- if ( isset( $options['GROUP BY'] ) ) $preLimitTail .= " GROUP BY {$options['GROUP BY']}";
- if ( isset( $options['HAVING'] ) ) $preLimitTail .= " HAVING {$options['HAVING']}";
- if ( isset( $options['ORDER BY'] ) ) $preLimitTail .= " ORDER BY {$options['ORDER BY']}";
+ if ( isset( $options['GROUP BY'] ) ) {
+ $preLimitTail .= " GROUP BY {$options['GROUP BY']}";
+ }
+ if ( isset( $options['HAVING'] ) ) {
+ $preLimitTail .= " HAVING {$options['HAVING']}";
+ }
+ if ( isset( $options['ORDER BY'] ) ) {
+ $preLimitTail .= " ORDER BY {$options['ORDER BY']}";
+ }
//if (isset($options['LIMIT'])) {
// $tailOpts .= $this->limitResult('', $options['LIMIT'],
// : false);
//}
- if ( isset( $noKeyOptions['FOR UPDATE'] ) ) $postLimitTail .= ' FOR UPDATE';
- if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) $postLimitTail .= ' LOCK IN SHARE MODE';
- if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) $startOpts .= 'DISTINCT';
+ if ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
+ $postLimitTail .= ' FOR UPDATE';
+ }
+ if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) {
+ $postLimitTail .= ' LOCK IN SHARE MODE';
+ }
+ if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) {
+ $startOpts .= 'DISTINCT';
+ }
# Various MySQL extensions
- if ( isset( $noKeyOptions['STRAIGHT_JOIN'] ) ) $startOpts .= ' /*! STRAIGHT_JOIN */';
- if ( isset( $noKeyOptions['HIGH_PRIORITY'] ) ) $startOpts .= ' HIGH_PRIORITY';
- if ( isset( $noKeyOptions['SQL_BIG_RESULT'] ) ) $startOpts .= ' SQL_BIG_RESULT';
- if ( isset( $noKeyOptions['SQL_BUFFER_RESULT'] ) ) $startOpts .= ' SQL_BUFFER_RESULT';
- if ( isset( $noKeyOptions['SQL_SMALL_RESULT'] ) ) $startOpts .= ' SQL_SMALL_RESULT';
- if ( isset( $noKeyOptions['SQL_CALC_FOUND_ROWS'] ) ) $startOpts .= ' SQL_CALC_FOUND_ROWS';
- if ( isset( $noKeyOptions['SQL_CACHE'] ) ) $startOpts .= ' SQL_CACHE';
- if ( isset( $noKeyOptions['SQL_NO_CACHE'] ) ) $startOpts .= ' SQL_NO_CACHE';
+ if ( isset( $noKeyOptions['STRAIGHT_JOIN'] ) ) {
+ $startOpts .= ' /*! STRAIGHT_JOIN */';
+ }
+ if ( isset( $noKeyOptions['HIGH_PRIORITY'] ) ) {
+ $startOpts .= ' HIGH_PRIORITY';
+ }
+ if ( isset( $noKeyOptions['SQL_BIG_RESULT'] ) ) {
+ $startOpts .= ' SQL_BIG_RESULT';
+ }
+ if ( isset( $noKeyOptions['SQL_BUFFER_RESULT'] ) ) {
+ $startOpts .= ' SQL_BUFFER_RESULT';
+ }
+ if ( isset( $noKeyOptions['SQL_SMALL_RESULT'] ) ) {
+ $startOpts .= ' SQL_SMALL_RESULT';
+ }
+ if ( isset( $noKeyOptions['SQL_CALC_FOUND_ROWS'] ) ) {
+ $startOpts .= ' SQL_CALC_FOUND_ROWS';
+ }
+ if ( isset( $noKeyOptions['SQL_CACHE'] ) ) {
+ $startOpts .= ' SQL_CACHE';
+ }
+ if ( isset( $noKeyOptions['SQL_NO_CACHE'] ) ) {
+ $startOpts .= ' SQL_NO_CACHE';
+ }
if ( isset( $options['USE INDEX'] ) && ! is_array( $options['USE INDEX'] ) ) {
$useIndex = $this->useIndexClause( $options['USE INDEX'] );
$options = array( $options );
}
if( is_array( $table ) ) {
- if ( !empty($join_conds) || ( isset( $options['USE INDEX'] ) && is_array( @$options['USE INDEX'] ) ) )
+ if ( !empty($join_conds) || ( isset( $options['USE INDEX'] ) && is_array( @$options['USE INDEX'] ) ) ) {
$from = ' FROM ' . $this->tableNamesWithUseIndexOrJOIN( $table, @$options['USE INDEX'], $join_conds );
- else
+ } else {
$from = ' FROM ' . implode( ',', array_map( array( &$this, 'tableName' ), $table ) );
+ }
} elseif ($table!='') {
if ($table{0}==' ') {
$from = ' FROM ' . $table;
function selectRow( $table, $vars, $conds, $fname = 'DatabaseBase::selectRow', $options = array(), $join_conds = array() ) {
$options['LIMIT'] = 1;
$res = $this->select( $table, $vars, $conds, $fname, $options, $join_conds );
- if ( $res === false )
+ if ( $res === false ) {
return false;
+ }
if ( !$this->numRows($res) ) {
return false;
}
} elseif ( ($mode == LIST_SET) && is_numeric( $field ) ) {
$list .= "$value";
} elseif ( ($mode == LIST_AND || $mode == LIST_OR) && is_array($value) ) {
- if( count( $value ) == 0 ) {
+ if ( count( $value ) == 0 ) {
throw new MWException( __METHOD__.': empty input' );
} elseif( count( $value ) == 1 ) {
// Special-case single values, as IN isn't terribly efficient
} else {
$list .= $field." IN (".$this->makeList($value).") ";
}
- } elseif( $value === null ) {
+ } elseif ( $value === null ) {
if ( $mode == LIST_AND || $mode == LIST_OR ) {
$list .= "$field IS ";
} elseif ( $mode == LIST_SET ) {
'un_user_id' => 'user_id',
'un_user_ip' => 'user_ip',
);
- if( isset( $renamed[$index] ) ) {
+ if ( isset( $renamed[$index] ) ) {
return $renamed[$index];
} else {
return $index;
$selectOptions = array( $selectOptions );
}
list( $startOpts, $useIndex, $tailOpts ) = $this->makeSelectOptions( $selectOptions );
- if( is_array( $srcTable ) ) {
+ if ( is_array( $srcTable ) ) {
$srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) );
} else {
$srcTable = $this->tableName( $srcTable );
$this->reportQueryError( $error, $errno, $sql, $fname );
}
}
- } while( $this->wasDeadlock() && --$tries > 0 );
+ } while ( $this->wasDeadlock() && --$tries > 0 );
$this->ignoreErrors( $oldIgnore );
if ( $tries <= 0 ) {
$this->rollback( $myFname );
* Local database timestamp format or null
*/
function timestampOrNull( $ts = null ) {
- if( is_null( $ts ) ) {
+ if ( is_null( $ts ) ) {
return null;
} else {
return $this->timestamp( $ts );
* @todo document
*/
function resultObject( $result ) {
- if( empty( $result ) ) {
+ if ( empty( $result ) ) {
return false;
} elseif ( $result instanceof ResultWrapper ) {
return $result;
$line = trim( fgets( $fp, 1024 ) );
$sl = strlen( $line ) - 1;
- if ( $sl < 0 ) { continue; }
- if ( '-' == $line{0} && '-' == $line{1} ) { continue; }
+ if ( $sl < 0 ) {
+ continue;
+ }
+ if ( '-' == $line{0} && '-' == $line{1} ) {
+ continue;
+ }
## Allow dollar quoting for function declarations
if (substr($line,0,4) == '$mw$') {
}
}
- if ( $cmd != '' ) { $cmd .= ' '; }
+ if ( $cmd != '' ) {
+ $cmd .= ' ';
+ }
$cmd .= "$line\n";
if ( $done ) {
// Ordinary variables
foreach ( $varnames as $var ) {
- if( isset( $GLOBALS[$var] ) ) {
+ if ( isset( $GLOBALS[$var] ) ) {
$val = addslashes( $GLOBALS[$var] ); // FIXME: safety check?
$ins = str_replace( '{$' . $var . '}', $val, $ins );
$ins = str_replace( '/*$' . $var . '*/`', '`' . $val, $ins );