Total Complexity | 9 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class Select extends Common |
||
8 | { |
||
9 | /** |
||
10 | * @var string $returnType PHP Type used for return result |
||
11 | */ |
||
12 | protected $returnType = ''; |
||
13 | |||
14 | /** |
||
15 | * Getter accessor to returnType property |
||
16 | * |
||
17 | * @return string |
||
18 | */ |
||
19 | public function getReturnType(): string |
||
20 | { |
||
21 | return $this->returnType; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Setter accessor to property returnType |
||
26 | * |
||
27 | * @param string $returnType The new return type value |
||
28 | * |
||
29 | * @return $this |
||
30 | */ |
||
31 | public function setReturnType(string $returnType): self |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Return the PDO constant for the returnType declared |
||
39 | * |
||
40 | * @return integer |
||
41 | */ |
||
42 | protected function obtainPdoFetchType(): int |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Fetch one row of the result |
||
53 | * |
||
54 | * @param bool $reexecute (default false) To reexecute the request, or just |
||
55 | * have the next line. |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function fetchRow(bool $reexecute = false) |
||
60 | { |
||
61 | if ($this->lastRequestStatement === null || $reexecute === true) { |
||
62 | $this->execute(); |
||
63 | } |
||
64 | |||
65 | return $this->lastRequestStatement->fetch($this->obtainPdoFetchType()); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Fetch all rows returned by the request |
||
70 | * |
||
71 | * @return \Generator |
||
72 | */ |
||
73 | public function fetchAll(): \Generator |
||
79 | } |
||
80 | } |
||
82 |