-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathQueryResult.php
87 lines (78 loc) · 1.83 KB
/
QueryResult.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace Aternos\Model\Query;
use Aternos\Model\ModelCollectionResult;
use Aternos\Model\ModelInterface;
/**
* Class QueryResult
*
* @template TModel of ModelInterface
* @extends ModelCollectionResult<TModel>
* @package Aternos\Model\Query
*/
class QueryResult extends ModelCollectionResult
{
/**
* Raw query string that was executed
*
* (mainly for debugging/logging reasons)
*
* @var string|null
*/
protected ?string $queryString = null;
/**
* Number of affected rows in update or delete queries
*
* @var int|null
*/
protected ?int $affectedRows = null;
/**
* QueryResult constructor.
*
* @param bool $success
* @param TModel[] $result
* @param string|null $queryString
*/
public function __construct(bool $success, array $result = [], ?string $queryString = null)
{
parent::__construct($success, $result);
$this->queryString = $queryString;
}
/**
* Get the executed query string
*
* @return string|null
*/
public function getQueryString(): ?string
{
return $this->queryString;
}
/**
* @param string|null $queryString
* @return QueryResult
*/
public function setQueryString(?string $queryString): QueryResult
{
if ($this->queryString === null) {
$this->queryString = $queryString;
}
return $this;
}
/**
* @return int|null
*/
public function getAffectedRows(): ?int
{
return $this->affectedRows;
}
/**
* @param int|null $affectedRows
* @return $this
*/
public function setAffectedRows(?int $affectedRows): static
{
if ($this->affectedRows === null) {
$this->affectedRows = $affectedRows;
}
return $this;
}
}