1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Plasma Core component |
4
|
|
|
* Copyright 2018 PlasmaPHP, All Rights Reserved |
5
|
|
|
* |
6
|
|
|
* Website: https://github.com/PlasmaPHP |
7
|
|
|
* License: https://github.com/PlasmaPHP/core/blob/master/LICENSE |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Plasma; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* A class representing a regular query result (no SELECT), with no event emitter. |
14
|
|
|
*/ |
15
|
|
|
class QueryResult implements QueryResultInterface { |
16
|
|
|
/** |
17
|
|
|
* @var int |
18
|
|
|
*/ |
19
|
|
|
protected $affectedRows; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var int |
23
|
|
|
*/ |
24
|
|
|
protected $warningsCount; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var int|null |
28
|
|
|
*/ |
29
|
|
|
protected $insertID; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var \Plasma\ColumnDefinitionInterface[]|null |
33
|
|
|
*/ |
34
|
|
|
protected $columns; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var array|null |
38
|
|
|
*/ |
39
|
|
|
protected $rows; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Constructor. |
43
|
|
|
* @param int $affectedRows |
44
|
|
|
* @param int $warningsCount |
45
|
|
|
* @param int|null $insertID |
46
|
|
|
* @param \Plasma\ColumnDefinitionInterface[]|null $columns |
47
|
|
|
* @param array|null $rows |
48
|
|
|
*/ |
49
|
9 |
|
function __construct(int $affectedRows, int $warningsCount, ?int $insertID, ?array $columns, ?array $rows) { |
50
|
9 |
|
$this->affectedRows = $affectedRows; |
51
|
9 |
|
$this->warningsCount = $warningsCount; |
52
|
9 |
|
$this->insertID = $insertID; |
53
|
9 |
|
$this->columns = $columns; |
54
|
9 |
|
$this->rows = $rows; |
55
|
9 |
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get the number of affected rows (for UPDATE, DELETE, etc.). |
59
|
|
|
* @return int |
60
|
|
|
*/ |
61
|
1 |
|
function getAffectedRows(): int { |
62
|
1 |
|
return $this->affectedRows; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get the number of warnings sent by the server. |
67
|
|
|
* @return int |
68
|
|
|
*/ |
69
|
1 |
|
function getWarningsCount(): int { |
70
|
1 |
|
return $this->warningsCount; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get the used insert ID for the row, if any. `INSERT` statements only. |
75
|
|
|
* @return int|null |
76
|
|
|
*/ |
77
|
1 |
|
function getInsertID(): ?int { |
78
|
1 |
|
return $this->insertID; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Get the field definitions, if any. `SELECT` statements only. |
83
|
|
|
* @return \Plasma\ColumnDefinitionInterface[]|null |
84
|
|
|
*/ |
85
|
2 |
|
function getFieldDefinitions(): ?array { |
86
|
2 |
|
return $this->columns; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get the rows, if any. `SELECT` statements only. |
91
|
|
|
* @return array|null |
92
|
|
|
*/ |
93
|
2 |
|
function getRows(): ?array { |
94
|
2 |
|
return $this->rows; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|