Total Complexity | 17 |
Total Lines | 133 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class ResultSetAdapter implements ResultSetAdapterInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var PDOStatement |
||
13 | */ |
||
14 | protected $statement; |
||
15 | |||
16 | /** |
||
17 | * @var bool |
||
18 | */ |
||
19 | protected $valid = true; |
||
20 | |||
21 | /** |
||
22 | * @param PDOStatement $statement |
||
23 | */ |
||
24 | public function __construct(PDOStatement $statement) |
||
25 | { |
||
26 | $this->statement = $statement; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @inheritdoc |
||
31 | */ |
||
32 | public function getAffectedRows() |
||
33 | { |
||
34 | return $this->statement->rowCount(); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @inheritdoc |
||
39 | */ |
||
40 | public function getNumRows() |
||
41 | { |
||
42 | return $this->statement->rowCount(); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @inheritdoc |
||
47 | */ |
||
48 | public function getFields() |
||
49 | { |
||
50 | $fields = array(); |
||
51 | |||
52 | for ($i = 0; $i < $this->statement->columnCount(); $i++) { |
||
53 | $fields[] = (object)$this->statement->getColumnMeta($i); |
||
54 | } |
||
55 | |||
56 | return $fields; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @inheritdoc |
||
61 | */ |
||
62 | public function isDml() |
||
63 | { |
||
64 | return $this->statement->columnCount() == 0; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @inheritdoc |
||
69 | */ |
||
70 | public function store() |
||
71 | { |
||
72 | return $this->statement->fetchAll(PDO::FETCH_NUM); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @inheritdoc |
||
77 | */ |
||
78 | public function toRow($num) |
||
79 | { |
||
80 | throw new \BadMethodCallException('Not implemented'); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @inheritdoc |
||
85 | */ |
||
86 | public function freeResult() |
||
87 | { |
||
88 | $this->statement->closeCursor(); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | public function rewind() |
||
95 | { |
||
96 | |||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | public function valid() |
||
103 | { |
||
104 | return $this->valid; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | public function fetch($assoc = true) |
||
111 | { |
||
112 | if ($assoc) { |
||
113 | $row = $this->statement->fetch(PDO::FETCH_ASSOC); |
||
114 | } else { |
||
115 | $row = $this->statement->fetch(PDO::FETCH_NUM); |
||
116 | } |
||
117 | |||
118 | if (!$row) { |
||
119 | $this->valid = false; |
||
120 | $row = null; |
||
121 | } |
||
122 | |||
123 | return $row; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @inheritdoc |
||
128 | */ |
||
129 | public function fetchAll($assoc = true) |
||
142 | } |
||
143 | } |
||
144 |