Add Database::queryMulti(), which will execute an array of queries as a batch with minimal roundtrips. SQLite fallbacks to looping through each statement and invoking doQuery(). Add QueryStatus class to reduce complexity in Database. Rewrite doQuery() as doSingleStatementQuery(). Change-Id: I3d51083e36ab06fcc1d94558e51b38e106f71bb9
66 lines
2 KiB
PHP
66 lines
2 KiB
PHP
<?php
|
|
/**
|
|
* @defgroup Database Database
|
|
*
|
|
* This file deals with database interface functions
|
|
* and query specifics/optimisations.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
*
|
|
* @file
|
|
* @ingroup Database
|
|
*/
|
|
namespace Wikimedia\Rdbms;
|
|
|
|
/**
|
|
* @internal This class should only be used by Database
|
|
* @since 1.39
|
|
*/
|
|
class QueryStatus {
|
|
/** @var ResultWrapper|bool|null Result set */
|
|
public $res;
|
|
/** @var int Returned row count */
|
|
public $rowsReturned;
|
|
/** @var int Affected row count */
|
|
public $rowsAffected;
|
|
/** @var string Error message or empty string */
|
|
public $message;
|
|
/** @var int|string Error code or zero */
|
|
public $code;
|
|
/** @var int Error flag bit field of Database::ERR_* constants */
|
|
public $flags;
|
|
|
|
/**
|
|
* @param ResultWrapper|bool|null $res
|
|
* @param int $affected
|
|
* @param string $error
|
|
* @param int|string $errno
|
|
*/
|
|
public function __construct( $res, int $affected, string $error, $errno ) {
|
|
if ( !( $res instanceof IResultWrapper ) && !is_bool( $res ) && $res !== null ) {
|
|
throw new DBUnexpectedError(
|
|
null,
|
|
'Got ' . gettype( $res ) . ' instead of IResultWrapper|bool'
|
|
);
|
|
}
|
|
$this->res = $res;
|
|
$this->rowsReturned = ( $res instanceof IResultWrapper ) ? $res->numRows() : 0;
|
|
$this->rowsAffected = $affected;
|
|
$this->message = $error;
|
|
$this->code = $errno;
|
|
$this->flags = 0;
|
|
}
|
|
}
|