if ( $wgProfiling ) {
# generalizeSQL will probably cut down the query to reasonable
# logging size most of the time. The substr is really just a sanity check.
- $profName = 'query: ' . substr( Database::generalizeSQL( $sql ), 0, 255 );
+ $profName = 'query: ' . $fname . ' ' . substr( Database::generalizeSQL( $sql ), 0, 255 );
wfProfileIn( 'Database::query' );
wfProfileIn( $profName );
}
function makeSelectOptions( $options ) {
$tailOpts = '';
+ if ( isset( $options['GROUP BY'] ) ) {
+ $tailOpts .= " GROUP BY {$options['GROUP BY']}";
+ }
if ( isset( $options['ORDER BY'] ) ) {
$tailOpts .= " ORDER BY {$options['ORDER BY']}";
}
}
/**
- * UPDATE wrapper, takes a condition array and a SET array
+ * Make UPDATE options for the Database::update function
+ *
+ * @access private
+ * @param array $options The options passed to Database::update
+ * @return string
*/
- function update( $table, $values, $conds, $fname = 'Database::update' ) {
+ function makeUpdateOptions( $options ) {
+ if( !is_array( $options ) ) {
+ wfDebugDieBacktrace( 'makeUpdateOptions given non-array' );
+ }
+ $opts = array();
+ if ( in_array( 'LOW_PRIORITY', $options ) )
+ $opts[] = $this->lowPriorityOption();
+ if ( in_array( 'IGNORE', $options ) )
+ $opts[] = 'IGNORE';
+ return implode(' ', $opts);
+ }
+
+ /**
+ * UPDATE wrapper, takes a condition array and a SET array
+ *
+ * @param string $table The table to UPDATE
+ * @param array $values An array of values to SET
+ * @param array $conds An array of conditions (WHERE)
+ * @param string $fname The Class::Function calling this function
+ * (for the log)
+ * @param array $options An array of UPDATE options, can be one or
+ * more of IGNORE, LOW_PRIORITY
+ */
+ function update( $table, $values, $conds, $fname = 'Database::update', $options = array() ) {
$table = $this->tableName( $table );
- $sql = "UPDATE $table SET " . $this->makeList( $values, LIST_SET );
+ $opts = $this->makeUpdateOptions( $options );
+ $sql = "UPDATE $opts $table SET " . $this->makeList( $values, LIST_SET );
if ( $conds != '*' ) {
$sql .= " WHERE " . $this->makeList( $conds, LIST_AND );
}
$list .= $field." IN (".$this->makeList($value).") ";
} else {
if ( $mode == LIST_AND || $mode == LIST_SET ) {
- $list .= $field.'=';
+ $list .= "$field = ";
}
- $list .= ($mode==LIST_NAMES?$value:$this->addQuotes( $value ));
+ $list .= $mode == LIST_NAMES ? $value : $this->addQuotes( $value );
}
}
return $list;
* PostgreSQL doesn't have them and returns ""
*/
function useIndexClause( $index ) {
- return "USE INDEX ($index)";
+ return "FORCE INDEX ($index)";
}
/**
/**
* @todo document
*/
- function &resultObject( &$result ) {
+ function resultObject( &$result ) {
if( empty( $result ) ) {
return NULL;
} else {
/**
* @todo document
*/
- function &fetchObject() {
+ function fetchObject() {
return $this->db->fetchObject( $this->result );
}