protected $preparedArgs;
+ protected $htmlErrors;
+
# ------------------------------------------------------------------------------
# Accessors
# ------------------------------------------------------------------------------
*
* @param $ignoreErrors bool|null
*
- * @return The previous value of the flag.
+ * @return bool The previous value of the flag.
*/
function ignoreErrors( $ignoreErrors = null ) {
return wfSetBit( $this->mFlags, DBO_IGNORE, $ignoreErrors );
/**
* Called by serialize. Throw an exception when DB connection is serialized.
- * This causes problems on some database engines because the connection is
+ * This causes problems on some database engines because the connection is
* not restored on unserialize.
*/
public function __sleep() {
* Same as new DatabaseMysql( ... ), kept for backward compatibility
* @deprecated since 1.17
*
+ * @param $server
+ * @param $user
+ * @param $password
+ * @param $dbName
+ * @param $flags int
* @return DatabaseMysql
*/
static function newFromParams( $server, $user, $password, $dbName, $flags = 0 ) {
}
}
+ /**
+ * @param $errno
+ * @param $errstr
+ */
protected function connectionErrorHandler( $errno, $errstr ) {
$this->mPHPError = $errstr;
}
# that would delay transaction initializations to once connection
# is really used by application
$sqlstart = substr( $sql, 0, 10 ); // very much worth it, benchmark certified(tm)
- if ( strpos( $sqlstart, "SHOW " ) !== 0 and strpos( $sqlstart, "SET " ) !== 0 )
+ if ( strpos( $sqlstart, "SHOW " ) !== 0 && strpos( $sqlstart, "SET " ) !== 0 )
$this->begin();
}
throw new MWException( 'Tainted query found' );
}
+ $queryId = MWDebug::query( $sql, $fname, $isMaster );
+
# Do the query and handle errors
$ret = $this->doQuery( $commentedSql );
+ MWDebug::queryTime( $queryId );
+
# Try reconnecting if the connection was lost
if ( false === $ret && $this->wasErrorReissuable() ) {
# Transaction is gone, like it or not
/**
* Free a prepared query, generated by prepare().
+ * @param $prepared
*/
function freePrepared( $prepared ) {
/* No-op by default */
* Query whether a given table exists
*
* @param $table string
+ * @param $fname string
*
* @return bool
*/
- function tableExists( $table ) {
+ function tableExists( $table, $fname = __METHOD__ ) {
$table = $this->tableName( $table );
$old = $this->ignoreErrors( true );
- $res = $this->query( "SELECT 1 FROM $table LIMIT 1", __METHOD__ );
+ $res = $this->query( "SELECT 1 FROM $table LIMIT 1", $fname );
$this->ignoreErrors( $old );
return (bool)$res;
}
/**
- * @todo document
* mysql_field_type() wrapper
+ * @param $res
+ * @param $index
+ * @return string
*/
function fieldType( $res, $index ) {
if ( $res instanceof ResultWrapper ) {
* Returns an appropriately quoted sequence value for inserting a new row.
* MySQL has autoincrement fields, so this is just NULL. But the PostgreSQL
* subclass will return an integer, and save the value for insertId()
+ *
+ * Any implementation of this function should *not* involve reusing
+ * sequence numbers created for rolled-back transactions.
+ * See http://bugs.mysql.com/bug.php?id=30767 for details.
+ * @param $seqName
+ * @return null
*/
function nextSequenceValue( $seqName ) {
return null;
* which index to pick. Anyway, other databases might have different
* indexes on a given table. So don't bother overriding this unless you're
* MySQL.
+ * @param $index
+ * @return string
*/
function useIndexClause( $index ) {
return '';
" FROM $srcTable $useIndex ";
if ( $conds != '*' ) {
- $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
+ if ( is_array( $conds ) ) {
+ $conds = $this->makeList( $conds, LIST_AND );
+ }
+ $sql .= " WHERE $conds";
}
$sql .= " $tailOpts";
return "REPLACE({$orig}, {$old}, {$new})";
}
+ /**
+ * Determines how long the server has been up
+ * STUB
+ *
+ * @return int
+ */
+ function getServerUptime() {
+ return 0;
+ }
+
/**
* Determines if the last failure was due to a deadlock
* STUB
return false;
}
+ /**
+ * Determines if the last failure was due to a lock timeout
+ * STUB
+ *
+ * @return bool
+ */
+ function wasLockTimeout() {
+ return false;
+ }
+
/**
* Determines if the last query error was something that should be dealt
* with by pinging the connection and reissuing the query.
*
* @param $result bool|ResultWrapper
*
- * @param bool|ResultWrapper
+ * @return bool|ResultWrapper
*/
function resultObject( $result ) {
if ( empty( $result ) ) {
* don't allow simple quoted strings to be inserted. To insert into such
* a field, pass the data through this function before passing it to
* DatabaseBase::insert().
+ * @param $b
+ * @return
*/
function encodeBlob( $b ) {
return $b;
* Some DBMSs return a special placeholder object representing blob fields
* in result objects. Pass the object through this function to return the
* original string.
+ * @param $b
+ * @return
*/
function decodeBlob( $b ) {
return $b;
}
/**
- * Override database's default connection timeout. May be useful for very
- * long batch queries such as full-wiki dumps, where a single query reads
- * out over hours or days. May or may not be necessary for non-MySQL
- * databases. For most purposes, leaving it as a no-op should be fine.
+ * Override database's default connection timeout
*
* @param $timeout Integer in seconds
+ * @return void
+ * @deprecated since 1.19; use setSessionOptions()
+ */
+ public function setTimeout( $timeout ) {
+ $this->setSessionOptions( array( 'connTimeout' => $timeout ) );
+ }
+
+ /**
+ * Override database's default behavior. $options include:
+ * 'connTimeout' : Set the connection timeout value in seconds.
+ * May be useful for very long batch queries such as
+ * full-wiki dumps, where a single query reads out over
+ * hours or days.
+ *
+ * @param $options Array
+ * @return void
*/
- public function setTimeout( $timeout ) {}
+ public function setSessionOptions( array $options ) {}
/**
* Read and execute SQL commands from a file.
* @param $resultCallback Callback: Optional function called for each MySQL result
* @param $fname String: Calling function name or false if name should be
* generated dynamically using $filename
+ * @return bool|string
*/
function sourceFile( $filename, $lineCallback = false, $resultCallback = false, $fname = false ) {
wfSuppressWarnings();
* @param $lineCallback Callback: Optional function called before reading each line
* @param $resultCallback Callback: Optional function called for each MySQL result
* @param $fname String: Calling function name
+ * @return bool|string
*/
function sourceStream( $fp, $lineCallback = false, $resultCallback = false,
$fname = 'DatabaseBase::sourceStream' )
/**
* Get schema variables. If none have been set via setSchemaVars(), then
* use some defaults from the current object.
+ *
+ * @return array
*/
protected function getSchemaVars() {
if ( $this->mSchemaVars ) {
* @param $tableName string
* @param $fName string
* @return bool|ResultWrapper
+ * @since 1.18
*/
public function dropTable( $tableName, $fName = 'DatabaseBase::dropTable' ) {
- if( !$this->tableExists( $tableName ) ) {
+ if( !$this->tableExists( $tableName, $fName ) ) {
return false;
}
$sql = "DROP TABLE " . $this->tableName( $tableName );