Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
QueryStatus
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6namespace Wikimedia\Rdbms;
7
8/**
9 * @since 1.39
10 * @ingroup Database
11 */
12class QueryStatus {
13    /** @var ResultWrapper|bool|null Result set */
14    public $res;
15    /** @var int Returned row count */
16    public $rowsReturned;
17    /** @var int Affected row count */
18    public $rowsAffected;
19    /** @var string Error message or empty string */
20    public $message;
21    /** @var int|string Error code or zero */
22    public $code;
23    /** @var int Error flag bit field of Database::ERR_* constants */
24    public $flags;
25
26    /**
27     * @internal Should only be constructed by Database
28     *
29     * @param ResultWrapper|bool|null $res
30     * @param int $affected
31     * @param string $error
32     * @param int|string $errno
33     */
34    public function __construct( $res, int $affected, string $error, $errno ) {
35        if ( !( $res instanceof IResultWrapper ) && !is_bool( $res ) && $res !== null ) {
36            throw new DBUnexpectedError(
37                null,
38                'Got ' . get_debug_type( $res ) . ' instead of IResultWrapper|bool'
39            );
40        }
41
42        $this->res = $res;
43        $this->rowsReturned = ( $res instanceof IResultWrapper ) ? $res->numRows() : 0;
44        $this->rowsAffected = $affected;
45        $this->message = $error;
46        $this->code = $errno;
47        $this->flags = 0;
48    }
49}