@@ -31,243 +31,243 @@ |
||
31 | 31 | */ |
32 | 32 | class ResultIterator implements Result, \ArrayAccess, \JsonSerializable |
33 | 33 | { |
34 | - /** |
|
35 | - * @var Statement |
|
36 | - */ |
|
37 | - protected $statement; |
|
38 | - |
|
39 | - protected $fetchStarted = false; |
|
40 | - private $objectStorage; |
|
41 | - private $className; |
|
42 | - |
|
43 | - private $tdbmService; |
|
44 | - private $magicSql; |
|
45 | - private $magicSqlCount; |
|
46 | - private $parameters; |
|
47 | - private $columnDescriptors; |
|
48 | - private $magicQuery; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var InnerResultIterator |
|
52 | - */ |
|
53 | - private $innerResultIterator; |
|
54 | - |
|
55 | - /** |
|
56 | - * The key of the current retrieved object. |
|
57 | - * |
|
58 | - * @var int |
|
59 | - */ |
|
60 | - protected $key = -1; |
|
61 | - |
|
62 | - protected $current = null; |
|
63 | - |
|
64 | - private $databasePlatform; |
|
65 | - |
|
66 | - private $totalCount; |
|
67 | - |
|
68 | - private $mode; |
|
69 | - |
|
70 | - private $logger; |
|
71 | - |
|
72 | - public function __construct($magicSql, $magicSqlCount, array $parameters, array $columnDescriptors, $objectStorage, $className, TDBMService $tdbmService, MagicQuery $magicQuery, $mode, LoggerInterface $logger) |
|
73 | - { |
|
74 | - $this->magicSql = $magicSql; |
|
75 | - $this->magicSqlCount = $magicSqlCount; |
|
76 | - $this->objectStorage = $objectStorage; |
|
77 | - $this->className = $className; |
|
78 | - $this->tdbmService = $tdbmService; |
|
79 | - $this->parameters = $parameters; |
|
80 | - $this->columnDescriptors = $columnDescriptors; |
|
81 | - $this->magicQuery = $magicQuery; |
|
82 | - $this->databasePlatform = $this->tdbmService->getConnection()->getDatabasePlatform(); |
|
83 | - $this->mode = $mode; |
|
84 | - $this->logger = $logger; |
|
85 | - } |
|
86 | - |
|
87 | - protected function executeCountQuery() |
|
88 | - { |
|
89 | - $sql = $this->magicQuery->build($this->magicSqlCount, $this->parameters); |
|
90 | - $this->logger->debug('Running count query: '.$sql); |
|
91 | - $this->totalCount = $this->tdbmService->getConnection()->fetchColumn($sql, $this->parameters); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Counts found records (this is the number of records fetched, taking into account the LIMIT and OFFSET settings). |
|
96 | - * |
|
97 | - * @return int |
|
98 | - */ |
|
99 | - public function count() |
|
100 | - { |
|
101 | - if ($this->totalCount === null) { |
|
102 | - $this->executeCountQuery(); |
|
103 | - } |
|
104 | - |
|
105 | - return $this->totalCount; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Casts the result set to a PHP array. |
|
110 | - * |
|
111 | - * @return array |
|
112 | - */ |
|
113 | - public function toArray() |
|
114 | - { |
|
115 | - return iterator_to_array($this->getIterator()); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Returns a new iterator mapping any call using the $callable function. |
|
120 | - * |
|
121 | - * @param callable $callable |
|
122 | - * |
|
123 | - * @return MapIterator |
|
124 | - */ |
|
125 | - public function map(callable $callable) |
|
126 | - { |
|
127 | - return new MapIterator($this->getIterator(), $callable); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Retrieve an external iterator. |
|
132 | - * |
|
133 | - * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
|
134 | - * |
|
135 | - * @return InnerResultIterator An instance of an object implementing <b>Iterator</b> or |
|
136 | - * <b>Traversable</b> |
|
137 | - * |
|
138 | - * @since 5.0.0 |
|
139 | - */ |
|
140 | - public function getIterator() |
|
141 | - { |
|
142 | - if ($this->innerResultIterator === null) { |
|
143 | - if ($this->mode === TDBMService::MODE_CURSOR) { |
|
144 | - $this->innerResultIterator = new InnerResultIterator($this->magicSql, $this->parameters, null, null, $this->columnDescriptors, $this->objectStorage, $this->className, $this->tdbmService, $this->magicQuery, $this->logger); |
|
145 | - } else { |
|
146 | - $this->innerResultIterator = new InnerResultArray($this->magicSql, $this->parameters, null, null, $this->columnDescriptors, $this->objectStorage, $this->className, $this->tdbmService, $this->magicQuery, $this->logger); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - return $this->innerResultIterator; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @param int $offset |
|
155 | - * |
|
156 | - * @return PageIterator |
|
157 | - */ |
|
158 | - public function take($offset, $limit) |
|
159 | - { |
|
160 | - return new PageIterator($this, $this->magicSql, $this->parameters, $limit, $offset, $this->columnDescriptors, $this->objectStorage, $this->className, $this->tdbmService, $this->magicQuery, $this->mode, $this->logger); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Whether a offset exists. |
|
165 | - * |
|
166 | - * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
167 | - * |
|
168 | - * @param mixed $offset <p> |
|
169 | - * An offset to check for. |
|
170 | - * </p> |
|
171 | - * |
|
172 | - * @return bool true on success or false on failure. |
|
173 | - * </p> |
|
174 | - * <p> |
|
175 | - * The return value will be casted to boolean if non-boolean was returned |
|
176 | - * |
|
177 | - * @since 5.0.0 |
|
178 | - */ |
|
179 | - public function offsetExists($offset) |
|
180 | - { |
|
181 | - return $this->getIterator()->offsetExists($offset); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Offset to retrieve. |
|
186 | - * |
|
187 | - * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
188 | - * |
|
189 | - * @param mixed $offset <p> |
|
190 | - * The offset to retrieve. |
|
191 | - * </p> |
|
192 | - * |
|
193 | - * @return mixed Can return all value types |
|
194 | - * |
|
195 | - * @since 5.0.0 |
|
196 | - */ |
|
197 | - public function offsetGet($offset) |
|
198 | - { |
|
199 | - return $this->getIterator()->offsetGet($offset); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Offset to set. |
|
204 | - * |
|
205 | - * @link http://php.net/manual/en/arrayaccess.offsetset.php |
|
206 | - * |
|
207 | - * @param mixed $offset <p> |
|
208 | - * The offset to assign the value to. |
|
209 | - * </p> |
|
210 | - * @param mixed $value <p> |
|
211 | - * The value to set. |
|
212 | - * </p> |
|
213 | - * |
|
214 | - * @since 5.0.0 |
|
215 | - */ |
|
216 | - public function offsetSet($offset, $value) |
|
217 | - { |
|
218 | - return $this->getIterator()->offsetSet($offset, $value); |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Offset to unset. |
|
223 | - * |
|
224 | - * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
|
225 | - * |
|
226 | - * @param mixed $offset <p> |
|
227 | - * The offset to unset. |
|
228 | - * </p> |
|
229 | - * |
|
230 | - * @since 5.0.0 |
|
231 | - */ |
|
232 | - public function offsetUnset($offset) |
|
233 | - { |
|
234 | - return $this->getIterator()->offsetUnset($offset); |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Specify data which should be serialized to JSON. |
|
239 | - * |
|
240 | - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
241 | - * |
|
242 | - * @param bool $stopRecursion Parameter used internally by TDBM to |
|
243 | - * stop embedded objects from embedding |
|
244 | - * other objects |
|
245 | - * |
|
246 | - * @return mixed data which can be serialized by <b>json_encode</b>, |
|
247 | - * which is a value of any type other than a resource |
|
248 | - * |
|
249 | - * @since 5.4.0 |
|
250 | - */ |
|
251 | - public function jsonSerialize($stopRecursion = false) |
|
252 | - { |
|
253 | - return array_map(function (AbstractTDBMObject $item) use ($stopRecursion) { |
|
254 | - return $item->jsonSerialize($stopRecursion); |
|
255 | - }, $this->toArray()); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Returns only one value (the first) of the result set. |
|
260 | - * Returns null if no value exists. |
|
261 | - * |
|
262 | - * @return mixed|null |
|
263 | - */ |
|
264 | - public function first() |
|
265 | - { |
|
266 | - $page = $this->take(0, 1); |
|
267 | - foreach ($page as $bean) { |
|
268 | - return $bean; |
|
269 | - } |
|
270 | - |
|
271 | - return; |
|
272 | - } |
|
34 | + /** |
|
35 | + * @var Statement |
|
36 | + */ |
|
37 | + protected $statement; |
|
38 | + |
|
39 | + protected $fetchStarted = false; |
|
40 | + private $objectStorage; |
|
41 | + private $className; |
|
42 | + |
|
43 | + private $tdbmService; |
|
44 | + private $magicSql; |
|
45 | + private $magicSqlCount; |
|
46 | + private $parameters; |
|
47 | + private $columnDescriptors; |
|
48 | + private $magicQuery; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var InnerResultIterator |
|
52 | + */ |
|
53 | + private $innerResultIterator; |
|
54 | + |
|
55 | + /** |
|
56 | + * The key of the current retrieved object. |
|
57 | + * |
|
58 | + * @var int |
|
59 | + */ |
|
60 | + protected $key = -1; |
|
61 | + |
|
62 | + protected $current = null; |
|
63 | + |
|
64 | + private $databasePlatform; |
|
65 | + |
|
66 | + private $totalCount; |
|
67 | + |
|
68 | + private $mode; |
|
69 | + |
|
70 | + private $logger; |
|
71 | + |
|
72 | + public function __construct($magicSql, $magicSqlCount, array $parameters, array $columnDescriptors, $objectStorage, $className, TDBMService $tdbmService, MagicQuery $magicQuery, $mode, LoggerInterface $logger) |
|
73 | + { |
|
74 | + $this->magicSql = $magicSql; |
|
75 | + $this->magicSqlCount = $magicSqlCount; |
|
76 | + $this->objectStorage = $objectStorage; |
|
77 | + $this->className = $className; |
|
78 | + $this->tdbmService = $tdbmService; |
|
79 | + $this->parameters = $parameters; |
|
80 | + $this->columnDescriptors = $columnDescriptors; |
|
81 | + $this->magicQuery = $magicQuery; |
|
82 | + $this->databasePlatform = $this->tdbmService->getConnection()->getDatabasePlatform(); |
|
83 | + $this->mode = $mode; |
|
84 | + $this->logger = $logger; |
|
85 | + } |
|
86 | + |
|
87 | + protected function executeCountQuery() |
|
88 | + { |
|
89 | + $sql = $this->magicQuery->build($this->magicSqlCount, $this->parameters); |
|
90 | + $this->logger->debug('Running count query: '.$sql); |
|
91 | + $this->totalCount = $this->tdbmService->getConnection()->fetchColumn($sql, $this->parameters); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Counts found records (this is the number of records fetched, taking into account the LIMIT and OFFSET settings). |
|
96 | + * |
|
97 | + * @return int |
|
98 | + */ |
|
99 | + public function count() |
|
100 | + { |
|
101 | + if ($this->totalCount === null) { |
|
102 | + $this->executeCountQuery(); |
|
103 | + } |
|
104 | + |
|
105 | + return $this->totalCount; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Casts the result set to a PHP array. |
|
110 | + * |
|
111 | + * @return array |
|
112 | + */ |
|
113 | + public function toArray() |
|
114 | + { |
|
115 | + return iterator_to_array($this->getIterator()); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Returns a new iterator mapping any call using the $callable function. |
|
120 | + * |
|
121 | + * @param callable $callable |
|
122 | + * |
|
123 | + * @return MapIterator |
|
124 | + */ |
|
125 | + public function map(callable $callable) |
|
126 | + { |
|
127 | + return new MapIterator($this->getIterator(), $callable); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Retrieve an external iterator. |
|
132 | + * |
|
133 | + * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
|
134 | + * |
|
135 | + * @return InnerResultIterator An instance of an object implementing <b>Iterator</b> or |
|
136 | + * <b>Traversable</b> |
|
137 | + * |
|
138 | + * @since 5.0.0 |
|
139 | + */ |
|
140 | + public function getIterator() |
|
141 | + { |
|
142 | + if ($this->innerResultIterator === null) { |
|
143 | + if ($this->mode === TDBMService::MODE_CURSOR) { |
|
144 | + $this->innerResultIterator = new InnerResultIterator($this->magicSql, $this->parameters, null, null, $this->columnDescriptors, $this->objectStorage, $this->className, $this->tdbmService, $this->magicQuery, $this->logger); |
|
145 | + } else { |
|
146 | + $this->innerResultIterator = new InnerResultArray($this->magicSql, $this->parameters, null, null, $this->columnDescriptors, $this->objectStorage, $this->className, $this->tdbmService, $this->magicQuery, $this->logger); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + return $this->innerResultIterator; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @param int $offset |
|
155 | + * |
|
156 | + * @return PageIterator |
|
157 | + */ |
|
158 | + public function take($offset, $limit) |
|
159 | + { |
|
160 | + return new PageIterator($this, $this->magicSql, $this->parameters, $limit, $offset, $this->columnDescriptors, $this->objectStorage, $this->className, $this->tdbmService, $this->magicQuery, $this->mode, $this->logger); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Whether a offset exists. |
|
165 | + * |
|
166 | + * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
167 | + * |
|
168 | + * @param mixed $offset <p> |
|
169 | + * An offset to check for. |
|
170 | + * </p> |
|
171 | + * |
|
172 | + * @return bool true on success or false on failure. |
|
173 | + * </p> |
|
174 | + * <p> |
|
175 | + * The return value will be casted to boolean if non-boolean was returned |
|
176 | + * |
|
177 | + * @since 5.0.0 |
|
178 | + */ |
|
179 | + public function offsetExists($offset) |
|
180 | + { |
|
181 | + return $this->getIterator()->offsetExists($offset); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Offset to retrieve. |
|
186 | + * |
|
187 | + * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
188 | + * |
|
189 | + * @param mixed $offset <p> |
|
190 | + * The offset to retrieve. |
|
191 | + * </p> |
|
192 | + * |
|
193 | + * @return mixed Can return all value types |
|
194 | + * |
|
195 | + * @since 5.0.0 |
|
196 | + */ |
|
197 | + public function offsetGet($offset) |
|
198 | + { |
|
199 | + return $this->getIterator()->offsetGet($offset); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Offset to set. |
|
204 | + * |
|
205 | + * @link http://php.net/manual/en/arrayaccess.offsetset.php |
|
206 | + * |
|
207 | + * @param mixed $offset <p> |
|
208 | + * The offset to assign the value to. |
|
209 | + * </p> |
|
210 | + * @param mixed $value <p> |
|
211 | + * The value to set. |
|
212 | + * </p> |
|
213 | + * |
|
214 | + * @since 5.0.0 |
|
215 | + */ |
|
216 | + public function offsetSet($offset, $value) |
|
217 | + { |
|
218 | + return $this->getIterator()->offsetSet($offset, $value); |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Offset to unset. |
|
223 | + * |
|
224 | + * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
|
225 | + * |
|
226 | + * @param mixed $offset <p> |
|
227 | + * The offset to unset. |
|
228 | + * </p> |
|
229 | + * |
|
230 | + * @since 5.0.0 |
|
231 | + */ |
|
232 | + public function offsetUnset($offset) |
|
233 | + { |
|
234 | + return $this->getIterator()->offsetUnset($offset); |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Specify data which should be serialized to JSON. |
|
239 | + * |
|
240 | + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
241 | + * |
|
242 | + * @param bool $stopRecursion Parameter used internally by TDBM to |
|
243 | + * stop embedded objects from embedding |
|
244 | + * other objects |
|
245 | + * |
|
246 | + * @return mixed data which can be serialized by <b>json_encode</b>, |
|
247 | + * which is a value of any type other than a resource |
|
248 | + * |
|
249 | + * @since 5.4.0 |
|
250 | + */ |
|
251 | + public function jsonSerialize($stopRecursion = false) |
|
252 | + { |
|
253 | + return array_map(function (AbstractTDBMObject $item) use ($stopRecursion) { |
|
254 | + return $item->jsonSerialize($stopRecursion); |
|
255 | + }, $this->toArray()); |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Returns only one value (the first) of the result set. |
|
260 | + * Returns null if no value exists. |
|
261 | + * |
|
262 | + * @return mixed|null |
|
263 | + */ |
|
264 | + public function first() |
|
265 | + { |
|
266 | + $page = $this->take(0, 1); |
|
267 | + foreach ($page as $bean) { |
|
268 | + return $bean; |
|
269 | + } |
|
270 | + |
|
271 | + return; |
|
272 | + } |
|
273 | 273 | } |
@@ -27,100 +27,100 @@ |
||
27 | 27 | */ |
28 | 28 | class InnerResultArray extends InnerResultIterator |
29 | 29 | { |
30 | - /** |
|
31 | - * The list of results already fetched. |
|
32 | - * |
|
33 | - * @var AbstractTDBMObject[] |
|
34 | - */ |
|
35 | - private $results = []; |
|
30 | + /** |
|
31 | + * The list of results already fetched. |
|
32 | + * |
|
33 | + * @var AbstractTDBMObject[] |
|
34 | + */ |
|
35 | + private $results = []; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Whether a offset exists. |
|
39 | - * |
|
40 | - * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
41 | - * |
|
42 | - * @param mixed $offset <p> |
|
43 | - * An offset to check for. |
|
44 | - * </p> |
|
45 | - * |
|
46 | - * @return bool true on success or false on failure. |
|
47 | - * </p> |
|
48 | - * <p> |
|
49 | - * The return value will be casted to boolean if non-boolean was returned |
|
50 | - * |
|
51 | - * @since 5.0.0 |
|
52 | - */ |
|
53 | - public function offsetExists($offset) |
|
54 | - { |
|
55 | - try { |
|
56 | - $this->toIndex($offset); |
|
57 | - } catch (TDBMInvalidOffsetException $e) { |
|
58 | - return false; |
|
59 | - } |
|
37 | + /** |
|
38 | + * Whether a offset exists. |
|
39 | + * |
|
40 | + * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
41 | + * |
|
42 | + * @param mixed $offset <p> |
|
43 | + * An offset to check for. |
|
44 | + * </p> |
|
45 | + * |
|
46 | + * @return bool true on success or false on failure. |
|
47 | + * </p> |
|
48 | + * <p> |
|
49 | + * The return value will be casted to boolean if non-boolean was returned |
|
50 | + * |
|
51 | + * @since 5.0.0 |
|
52 | + */ |
|
53 | + public function offsetExists($offset) |
|
54 | + { |
|
55 | + try { |
|
56 | + $this->toIndex($offset); |
|
57 | + } catch (TDBMInvalidOffsetException $e) { |
|
58 | + return false; |
|
59 | + } |
|
60 | 60 | |
61 | - return true; |
|
62 | - } |
|
61 | + return true; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Offset to retrieve. |
|
66 | - * |
|
67 | - * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
68 | - * |
|
69 | - * @param mixed $offset <p> |
|
70 | - * The offset to retrieve. |
|
71 | - * </p> |
|
72 | - * |
|
73 | - * @return mixed Can return all value types |
|
74 | - * |
|
75 | - * @since 5.0.0 |
|
76 | - */ |
|
77 | - public function offsetGet($offset) |
|
78 | - { |
|
79 | - $this->toIndex($offset); |
|
64 | + /** |
|
65 | + * Offset to retrieve. |
|
66 | + * |
|
67 | + * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
68 | + * |
|
69 | + * @param mixed $offset <p> |
|
70 | + * The offset to retrieve. |
|
71 | + * </p> |
|
72 | + * |
|
73 | + * @return mixed Can return all value types |
|
74 | + * |
|
75 | + * @since 5.0.0 |
|
76 | + */ |
|
77 | + public function offsetGet($offset) |
|
78 | + { |
|
79 | + $this->toIndex($offset); |
|
80 | 80 | |
81 | - return $this->results[$offset]; |
|
82 | - } |
|
81 | + return $this->results[$offset]; |
|
82 | + } |
|
83 | 83 | |
84 | - private function toIndex($offset) |
|
85 | - { |
|
86 | - if ($offset < 0 || filter_var($offset, FILTER_VALIDATE_INT) === false) { |
|
87 | - throw new TDBMInvalidOffsetException('Trying to access result set using offset "'.$offset.'". An offset must be a positive integer.'); |
|
88 | - } |
|
89 | - if ($this->statement === null) { |
|
90 | - $this->executeQuery(); |
|
91 | - } |
|
92 | - while (!isset($this->results[$offset])) { |
|
93 | - $this->next(); |
|
94 | - if ($this->current === null) { |
|
95 | - throw new TDBMInvalidOffsetException('Offset "'.$offset.'" does not exist in result set.'); |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
84 | + private function toIndex($offset) |
|
85 | + { |
|
86 | + if ($offset < 0 || filter_var($offset, FILTER_VALIDATE_INT) === false) { |
|
87 | + throw new TDBMInvalidOffsetException('Trying to access result set using offset "'.$offset.'". An offset must be a positive integer.'); |
|
88 | + } |
|
89 | + if ($this->statement === null) { |
|
90 | + $this->executeQuery(); |
|
91 | + } |
|
92 | + while (!isset($this->results[$offset])) { |
|
93 | + $this->next(); |
|
94 | + if ($this->current === null) { |
|
95 | + throw new TDBMInvalidOffsetException('Offset "'.$offset.'" does not exist in result set.'); |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - public function next() |
|
101 | - { |
|
102 | - // Let's overload the next() method to store the result. |
|
103 | - if (isset($this->results[$this->key + 1])) { |
|
104 | - ++$this->key; |
|
105 | - $this->current = $this->results[$this->key]; |
|
106 | - } else { |
|
107 | - parent::next(); |
|
108 | - if ($this->current !== null) { |
|
109 | - $this->results[$this->key] = $this->current; |
|
110 | - } |
|
111 | - } |
|
112 | - } |
|
100 | + public function next() |
|
101 | + { |
|
102 | + // Let's overload the next() method to store the result. |
|
103 | + if (isset($this->results[$this->key + 1])) { |
|
104 | + ++$this->key; |
|
105 | + $this->current = $this->results[$this->key]; |
|
106 | + } else { |
|
107 | + parent::next(); |
|
108 | + if ($this->current !== null) { |
|
109 | + $this->results[$this->key] = $this->current; |
|
110 | + } |
|
111 | + } |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Overloads the rewind implementation. |
|
116 | - * Do not reexecute the query. |
|
117 | - */ |
|
118 | - public function rewind() |
|
119 | - { |
|
120 | - if (!$this->fetchStarted) { |
|
121 | - $this->executeQuery(); |
|
122 | - } |
|
123 | - $this->key = -1; |
|
124 | - $this->next(); |
|
125 | - } |
|
114 | + /** |
|
115 | + * Overloads the rewind implementation. |
|
116 | + * Do not reexecute the query. |
|
117 | + */ |
|
118 | + public function rewind() |
|
119 | + { |
|
120 | + if (!$this->fetchStarted) { |
|
121 | + $this->executeQuery(); |
|
122 | + } |
|
123 | + $this->key = -1; |
|
124 | + $this->next(); |
|
125 | + } |
|
126 | 126 | } |
@@ -33,42 +33,42 @@ |
||
33 | 33 | */ |
34 | 34 | class TDBMObject extends AbstractTDBMObject |
35 | 35 | { |
36 | - public function getProperty($var, $tableName = null) |
|
37 | - { |
|
38 | - return $this->get($var, $tableName); |
|
39 | - } |
|
36 | + public function getProperty($var, $tableName = null) |
|
37 | + { |
|
38 | + return $this->get($var, $tableName); |
|
39 | + } |
|
40 | 40 | |
41 | - public function setProperty($var, $value, $tableName = null) |
|
42 | - { |
|
43 | - $this->set($var, $value, $tableName); |
|
44 | - } |
|
41 | + public function setProperty($var, $value, $tableName = null) |
|
42 | + { |
|
43 | + $this->set($var, $value, $tableName); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Specify data which should be serialized to JSON. |
|
48 | - * |
|
49 | - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
50 | - * |
|
51 | - * @return mixed data which can be serialized by <b>json_encode</b>, |
|
52 | - * which is a value of any type other than a resource |
|
53 | - * |
|
54 | - * @since 5.4.0 |
|
55 | - */ |
|
56 | - public function jsonSerialize() |
|
57 | - { |
|
58 | - throw new TDBMException('Json serialization is only implemented for generated beans.'); |
|
59 | - } |
|
46 | + /** |
|
47 | + * Specify data which should be serialized to JSON. |
|
48 | + * |
|
49 | + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
50 | + * |
|
51 | + * @return mixed data which can be serialized by <b>json_encode</b>, |
|
52 | + * which is a value of any type other than a resource |
|
53 | + * |
|
54 | + * @since 5.4.0 |
|
55 | + */ |
|
56 | + public function jsonSerialize() |
|
57 | + { |
|
58 | + throw new TDBMException('Json serialization is only implemented for generated beans.'); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Returns an array of used tables by this bean (from parent to child relationship). |
|
63 | - * |
|
64 | - * @return string[] |
|
65 | - */ |
|
66 | - protected function getUsedTables() |
|
67 | - { |
|
68 | - $tableNames = array_keys($this->dbRows); |
|
69 | - $tableNames = $this->tdbmService->_getLinkBetweenInheritedTables($tableNames); |
|
70 | - $tableNames = array_reverse($tableNames); |
|
61 | + /** |
|
62 | + * Returns an array of used tables by this bean (from parent to child relationship). |
|
63 | + * |
|
64 | + * @return string[] |
|
65 | + */ |
|
66 | + protected function getUsedTables() |
|
67 | + { |
|
68 | + $tableNames = array_keys($this->dbRows); |
|
69 | + $tableNames = $this->tdbmService->_getLinkBetweenInheritedTables($tableNames); |
|
70 | + $tableNames = array_reverse($tableNames); |
|
71 | 71 | |
72 | - return $tableNames; |
|
73 | - } |
|
72 | + return $tableNames; |
|
73 | + } |
|
74 | 74 | } |