@@ -25,7 +25,7 @@ |
||
25 | 25 | private $_command; |
26 | 26 | private $_result; |
27 | 27 | |
28 | - public function __construct($command,$result) |
|
28 | + public function __construct($command, $result) |
|
29 | 29 | { |
30 | 30 | $this->_command=$command; |
31 | 31 | $this->_result=$result; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct($builder) |
45 | 45 | { |
46 | - $this->_builder = $builder; |
|
46 | + $this->_builder=$builder; |
|
47 | 47 | } |
48 | 48 | /** |
49 | 49 | * @return TDbTableInfo |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function delete($criteria) |
75 | 75 | { |
76 | - $where = $criteria->getCondition(); |
|
77 | - $parameters = $criteria->getParameters()->toArray(); |
|
78 | - $command = $this->getBuilder()->createDeleteCommand($where, $parameters); |
|
79 | - $this->onCreateCommand($command,$criteria); |
|
76 | + $where=$criteria->getCondition(); |
|
77 | + $parameters=$criteria->getParameters()->toArray(); |
|
78 | + $command=$this->getBuilder()->createDeleteCommand($where, $parameters); |
|
79 | + $this->onCreateCommand($command, $criteria); |
|
80 | 80 | $command->prepare(); |
81 | 81 | return $command->execute(); |
82 | 82 | } |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function update($data, $criteria) |
90 | 90 | { |
91 | - $where = $criteria->getCondition(); |
|
92 | - $parameters = $criteria->getParameters()->toArray(); |
|
93 | - $command = $this->getBuilder()->createUpdateCommand($data,$where, $parameters); |
|
94 | - $this->onCreateCommand($command,$criteria); |
|
91 | + $where=$criteria->getCondition(); |
|
92 | + $parameters=$criteria->getParameters()->toArray(); |
|
93 | + $command=$this->getBuilder()->createUpdateCommand($data, $where, $parameters); |
|
94 | + $this->onCreateCommand($command, $criteria); |
|
95 | 95 | $command->prepare(); |
96 | 96 | return $this->onExecuteCommand($command, $command->execute()); |
97 | 97 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function updateByPk($data, $keys) |
104 | 104 | { |
105 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
105 | + list($where, $parameters)=$this->getPrimaryKeyCondition((array) $keys); |
|
106 | 106 | return $this->update($data, new TSqlCriteria($where, $parameters)); |
107 | 107 | } |
108 | 108 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function find($criteria) |
114 | 114 | { |
115 | - $command = $this->getFindCommand($criteria); |
|
115 | + $command=$this->getFindCommand($criteria); |
|
116 | 116 | return $this->onExecuteCommand($command, $command->queryRow()); |
117 | 117 | } |
118 | 118 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function findAll($criteria) |
124 | 124 | { |
125 | - $command = $this->getFindCommand($criteria); |
|
125 | + $command=$this->getFindCommand($criteria); |
|
126 | 126 | return $this->onExecuteCommand($command, $command->query()); |
127 | 127 | } |
128 | 128 | /** |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | { |
135 | 135 | if($criteria===null) |
136 | 136 | return $this->getBuilder()->createFindCommand(); |
137 | - $where = $criteria->getCondition(); |
|
138 | - $parameters = $criteria->getParameters()->toArray(); |
|
139 | - $ordering = $criteria->getOrdersBy(); |
|
140 | - $limit = $criteria->getLimit(); |
|
141 | - $offset = $criteria->getOffset(); |
|
142 | - $select = $criteria->getSelect(); |
|
143 | - $command = $this->getBuilder()->createFindCommand($where,$parameters,$ordering,$limit,$offset,$select); |
|
137 | + $where=$criteria->getCondition(); |
|
138 | + $parameters=$criteria->getParameters()->toArray(); |
|
139 | + $ordering=$criteria->getOrdersBy(); |
|
140 | + $limit=$criteria->getLimit(); |
|
141 | + $offset=$criteria->getOffset(); |
|
142 | + $select=$criteria->getSelect(); |
|
143 | + $command=$this->getBuilder()->createFindCommand($where, $parameters, $ordering, $limit, $offset, $select); |
|
144 | 144 | $this->onCreateCommand($command, $criteria); |
145 | 145 | return $command; |
146 | 146 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | { |
153 | 153 | if($keys===null) |
154 | 154 | return null; |
155 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
156 | - $command = $this->getBuilder()->createFindCommand($where, $parameters); |
|
157 | - $this->onCreateCommand($command, new TSqlCriteria($where,$parameters)); |
|
155 | + list($where, $parameters)=$this->getPrimaryKeyCondition((array) $keys); |
|
156 | + $command=$this->getBuilder()->createFindCommand($where, $parameters); |
|
157 | + $this->onCreateCommand($command, new TSqlCriteria($where, $parameters)); |
|
158 | 158 | return $this->onExecuteCommand($command, $command->queryRow()); |
159 | 159 | } |
160 | 160 | /** |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function findAllByPk($keys) |
165 | 165 | { |
166 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
167 | - $command = $this->getBuilder()->createFindCommand($where); |
|
168 | - $this->onCreateCommand($command, new TSqlCriteria($where,$keys)); |
|
169 | - return $this->onExecuteCommand($command,$command->query()); |
|
166 | + $where=$this->getCompositeKeyCondition((array) $keys); |
|
167 | + $command=$this->getBuilder()->createFindCommand($where); |
|
168 | + $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
|
169 | + return $this->onExecuteCommand($command, $command->query()); |
|
170 | 170 | } |
171 | - public function findAllByIndex($criteria,$fields,$values) |
|
171 | + public function findAllByIndex($criteria, $fields, $values) |
|
172 | 172 | { |
173 | - $index = $this->getIndexKeyCondition($this->getTableInfo(),$fields,$values); |
|
174 | - if(strlen($where = $criteria->getCondition())>0) |
|
173 | + $index=$this->getIndexKeyCondition($this->getTableInfo(), $fields, $values); |
|
174 | + if(strlen($where=$criteria->getCondition()) > 0) |
|
175 | 175 | $criteria->setCondition("({$index}) AND ({$where})"); |
176 | 176 | else |
177 | 177 | $criteria->setCondition($index); |
178 | - $command = $this->getFindCommand($criteria); |
|
178 | + $command=$this->getFindCommand($criteria); |
|
179 | 179 | $this->onCreateCommand($command, $criteria); |
180 | - return $this->onExecuteCommand($command,$command->query()); |
|
180 | + return $this->onExecuteCommand($command, $command->query()); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -188,22 +188,22 @@ discard block |
||
188 | 188 | { |
189 | 189 | if(count($keys)==0) |
190 | 190 | return 0; |
191 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
192 | - $command = $this->getBuilder()->createDeleteCommand($where); |
|
193 | - $this->onCreateCommand($command, new TSqlCriteria($where,$keys)); |
|
191 | + $where=$this->getCompositeKeyCondition((array) $keys); |
|
192 | + $command=$this->getBuilder()->createDeleteCommand($where); |
|
193 | + $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
|
194 | 194 | $command->prepare(); |
195 | - return $this->onExecuteCommand($command,$command->execute()); |
|
195 | + return $this->onExecuteCommand($command, $command->execute()); |
|
196 | 196 | } |
197 | 197 | |
198 | - public function getIndexKeyCondition($table,$fields,$values) |
|
198 | + public function getIndexKeyCondition($table, $fields, $values) |
|
199 | 199 | { |
200 | - if (!count($values)) |
|
200 | + if(!count($values)) |
|
201 | 201 | return 'FALSE'; |
202 | - $columns = array(); |
|
203 | - $tableName = $table->getTableFullName(); |
|
202 | + $columns=array(); |
|
203 | + $tableName=$table->getTableFullName(); |
|
204 | 204 | foreach($fields as $field) |
205 | - $columns[] = $tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
206 | - return '('.implode(', ',$columns).') IN '.$this->quoteTuple($values); |
|
205 | + $columns[]=$tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
206 | + return '('.implode(', ', $columns).') IN '.$this->quoteTuple($values); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -213,26 +213,26 @@ discard block |
||
213 | 213 | */ |
214 | 214 | protected function getCompositeKeyCondition($values) |
215 | 215 | { |
216 | - $primary = $this->getTableInfo()->getPrimaryKeys(); |
|
217 | - $count = count($primary); |
|
216 | + $primary=$this->getTableInfo()->getPrimaryKeys(); |
|
217 | + $count=count($primary); |
|
218 | 218 | if($count===0) |
219 | 219 | { |
220 | 220 | throw new TDbException('dbtablegateway_no_primary_key_found', |
221 | 221 | $this->getTableInfo()->getTableFullName()); |
222 | 222 | } |
223 | - if(!is_array($values) || count($values) === 0) |
|
223 | + if(!is_array($values) || count($values)===0) |
|
224 | 224 | { |
225 | 225 | throw new TDbException('dbtablegateway_missing_pk_values', |
226 | 226 | $this->getTableInfo()->getTableFullName()); |
227 | 227 | } |
228 | - if($count>1 && (!isset($values[0]) || !is_array($values[0]))) |
|
229 | - $values = array($values); |
|
230 | - if($count > 1 && count($values[0]) !== $count) |
|
228 | + if($count > 1 && (!isset($values[0]) || !is_array($values[0]))) |
|
229 | + $values=array($values); |
|
230 | + if($count > 1 && count($values[0])!==$count) |
|
231 | 231 | { |
232 | 232 | throw new TDbException('dbtablegateway_pk_value_count_mismatch', |
233 | 233 | $this->getTableInfo()->getTableFullName()); |
234 | 234 | } |
235 | - return $this->getIndexKeyCondition($this->getTableInfo(),$primary, $values); |
|
235 | + return $this->getIndexKeyCondition($this->getTableInfo(), $primary, $values); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | */ |
243 | 243 | protected function quoteTuple($array) |
244 | 244 | { |
245 | - $conn = $this->getDbConnection(); |
|
246 | - $data = array(); |
|
245 | + $conn=$this->getDbConnection(); |
|
246 | + $data=array(); |
|
247 | 247 | foreach($array as $k=>$v) |
248 | - $data[] = is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
248 | + $data[]=is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
249 | 249 | return '('.implode(', ', $data).')'; |
250 | 250 | } |
251 | 251 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | protected function getPrimaryKeyCondition($values) |
258 | 258 | { |
259 | - $primary = $this->getTableInfo()->getPrimaryKeys(); |
|
259 | + $primary=$this->getTableInfo()->getPrimaryKeys(); |
|
260 | 260 | if(count($primary)===0) |
261 | 261 | { |
262 | 262 | throw new TDbException('dbtablegateway_no_primary_key_found', |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | } |
265 | 265 | $criteria=array(); |
266 | 266 | $bindings=array(); |
267 | - $i = 0; |
|
267 | + $i=0; |
|
268 | 268 | foreach($primary as $key) |
269 | 269 | { |
270 | - $column = $this->getTableInfo()->getColumn($key)->getColumnName(); |
|
271 | - $criteria[] = $column.' = :'.$key; |
|
272 | - $bindings[$key] = isset($values[$key])?$values[$key]:$values[$i++]; |
|
270 | + $column=$this->getTableInfo()->getColumn($key)->getColumnName(); |
|
271 | + $criteria[]=$column.' = :'.$key; |
|
272 | + $bindings[$key]=isset($values[$key]) ? $values[$key] : $values[$i++]; |
|
273 | 273 | } |
274 | 274 | return array(implode(' AND ', $criteria), $bindings); |
275 | 275 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function findBySql($criteria) |
283 | 283 | { |
284 | - $command = $this->getSqlCommand($criteria); |
|
284 | + $command=$this->getSqlCommand($criteria); |
|
285 | 285 | return $this->onExecuteCommand($command, $command->queryRow()); |
286 | 286 | } |
287 | 287 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function findAllBySql($criteria) |
294 | 294 | { |
295 | - $command = $this->getSqlCommand($criteria); |
|
295 | + $command=$this->getSqlCommand($criteria); |
|
296 | 296 | return $this->onExecuteCommand($command, $command->query()); |
297 | 297 | } |
298 | 298 | |
@@ -303,15 +303,15 @@ discard block |
||
303 | 303 | */ |
304 | 304 | protected function getSqlCommand($criteria) |
305 | 305 | { |
306 | - $sql = $criteria->getCondition(); |
|
307 | - $ordering = $criteria->getOrdersBy(); |
|
308 | - $limit = $criteria->getLimit(); |
|
309 | - $offset = $criteria->getOffset(); |
|
306 | + $sql=$criteria->getCondition(); |
|
307 | + $ordering=$criteria->getOrdersBy(); |
|
308 | + $limit=$criteria->getLimit(); |
|
309 | + $offset=$criteria->getOffset(); |
|
310 | 310 | if(count($ordering) > 0) |
311 | - $sql = $this->getBuilder()->applyOrdering($sql, $ordering); |
|
312 | - if($limit>=0 || $offset>=0) |
|
313 | - $sql = $this->getBuilder()->applyLimitOffset($sql, $limit, $offset); |
|
314 | - $command = $this->getBuilder()->createCommand($sql); |
|
311 | + $sql=$this->getBuilder()->applyOrdering($sql, $ordering); |
|
312 | + if($limit >= 0 || $offset >= 0) |
|
313 | + $sql=$this->getBuilder()->applyLimitOffset($sql, $limit, $offset); |
|
314 | + $command=$this->getBuilder()->createCommand($sql); |
|
315 | 315 | $this->getBuilder()->bindArrayValues($command, $criteria->getParameters()->toArray()); |
316 | 316 | $this->onCreateCommand($command, $criteria); |
317 | 317 | return $command; |
@@ -324,15 +324,15 @@ discard block |
||
324 | 324 | public function count($criteria) |
325 | 325 | { |
326 | 326 | if($criteria===null) |
327 | - return (int)$this->getBuilder()->createCountCommand()->queryScalar(); |
|
328 | - $where = $criteria->getCondition(); |
|
329 | - $parameters = $criteria->getParameters()->toArray(); |
|
330 | - $ordering = $criteria->getOrdersBy(); |
|
331 | - $limit = $criteria->getLimit(); |
|
332 | - $offset = $criteria->getOffset(); |
|
333 | - $command = $this->getBuilder()->createCountCommand($where,$parameters,$ordering,$limit,$offset); |
|
327 | + return (int) $this->getBuilder()->createCountCommand()->queryScalar(); |
|
328 | + $where=$criteria->getCondition(); |
|
329 | + $parameters=$criteria->getParameters()->toArray(); |
|
330 | + $ordering=$criteria->getOrdersBy(); |
|
331 | + $limit=$criteria->getLimit(); |
|
332 | + $offset=$criteria->getOffset(); |
|
333 | + $command=$this->getBuilder()->createCountCommand($where, $parameters, $ordering, $limit, $offset); |
|
334 | 334 | $this->onCreateCommand($command, $criteria); |
335 | - return $this->onExecuteCommand($command, (int)$command->queryScalar()); |
|
335 | + return $this->onExecuteCommand($command, (int) $command->queryScalar()); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -345,12 +345,12 @@ discard block |
||
345 | 345 | public function insert($data) |
346 | 346 | { |
347 | 347 | $command=$this->getBuilder()->createInsertCommand($data); |
348 | - $this->onCreateCommand($command, new TSqlCriteria(null,$data)); |
|
348 | + $this->onCreateCommand($command, new TSqlCriteria(null, $data)); |
|
349 | 349 | $command->prepare(); |
350 | 350 | if($this->onExecuteCommand($command, $command->execute()) > 0) |
351 | 351 | { |
352 | - $value = $this->getLastInsertId(); |
|
353 | - return $value !== null ? $value : true; |
|
352 | + $value=$this->getLastInsertId(); |
|
353 | + return $value!==null ? $value : true; |
|
354 | 354 | } |
355 | 355 | return false; |
356 | 356 | } |
@@ -373,14 +373,14 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function createCriteriaFromString($method, $condition, $args) |
375 | 375 | { |
376 | - $fields = $this->extractMatchingConditions($method, $condition); |
|
377 | - $args=count($args) === 1 && is_array($args[0]) ? $args[0] : $args; |
|
378 | - if(count($fields)>count($args)) |
|
376 | + $fields=$this->extractMatchingConditions($method, $condition); |
|
377 | + $args=count($args)===1 && is_array($args[0]) ? $args[0] : $args; |
|
378 | + if(count($fields) > count($args)) |
|
379 | 379 | { |
380 | 380 | throw new TDbException('dbtablegateway_mismatch_args_exception', |
381 | - $method,count($fields),count($args)); |
|
381 | + $method, count($fields), count($args)); |
|
382 | 382 | } |
383 | - return new TSqlCriteria(implode(' ',$fields), $args); |
|
383 | + return new TSqlCriteria(implode(' ', $fields), $args); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -392,25 +392,25 @@ discard block |
||
392 | 392 | */ |
393 | 393 | protected function extractMatchingConditions($method, $condition) |
394 | 394 | { |
395 | - $table = $this->getTableInfo(); |
|
396 | - $columns = $table->getLowerCaseColumnNames(); |
|
397 | - $regexp = '/('.implode('|', array_keys($columns)).')(and|_and_|or|_or_)?/i'; |
|
398 | - $matches = array(); |
|
399 | - if(!preg_match_all($regexp, strtolower($condition), $matches,PREG_SET_ORDER)) |
|
395 | + $table=$this->getTableInfo(); |
|
396 | + $columns=$table->getLowerCaseColumnNames(); |
|
397 | + $regexp='/('.implode('|', array_keys($columns)).')(and|_and_|or|_or_)?/i'; |
|
398 | + $matches=array(); |
|
399 | + if(!preg_match_all($regexp, strtolower($condition), $matches, PREG_SET_ORDER)) |
|
400 | 400 | { |
401 | 401 | throw new TDbException('dbtablegateway_mismatch_column_name', |
402 | 402 | $method, implode(', ', $columns), $table->getTableFullName()); |
403 | 403 | } |
404 | 404 | |
405 | - $fields = array(); |
|
405 | + $fields=array(); |
|
406 | 406 | foreach($matches as $match) |
407 | 407 | { |
408 | - $key = $columns[$match[1]]; |
|
409 | - $column = $table->getColumn($key)->getColumnName(); |
|
410 | - $sql = $column . ' = ? '; |
|
408 | + $key=$columns[$match[1]]; |
|
409 | + $column=$table->getColumn($key)->getColumnName(); |
|
410 | + $sql=$column.' = ? '; |
|
411 | 411 | if(count($match) > 2) |
412 | - $sql .= strtoupper(str_replace('_', '', $match[2])); |
|
413 | - $fields[] = $sql; |
|
412 | + $sql.=strtoupper(str_replace('_', '', $match[2])); |
|
413 | + $fields[]=$sql; |
|
414 | 414 | } |
415 | 415 | return $fields; |
416 | 416 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public function onCreateCommand($command, $criteria) |
427 | 427 | { |
428 | - $this->raiseEvent('OnCreateCommand', $this, new TDataGatewayEventParameter($command,$criteria)); |
|
428 | + $this->raiseEvent('OnCreateCommand', $this, new TDataGatewayEventParameter($command, $criteria)); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | public function onExecuteCommand($command, $result) |
441 | 441 | { |
442 | - $parameter = new TDataGatewayResultEventParameter($command, $result); |
|
442 | + $parameter=new TDataGatewayResultEventParameter($command, $result); |
|
443 | 443 | $this->raiseEvent('OnExecuteCommand', $this, $parameter); |
444 | 444 | return $parameter->getResult(); |
445 | 445 | } |
@@ -26,9 +26,9 @@ |
||
26 | 26 | |
27 | 27 | public function __construct($result, $parameter, &$list) |
28 | 28 | { |
29 | - $this->_resultObject = $result; |
|
30 | - $this->_parameterObject = $parameter; |
|
31 | - $this->_list = &$list; |
|
29 | + $this->_resultObject=$result; |
|
30 | + $this->_parameterObject=$parameter; |
|
31 | + $this->_list=&$list; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function getResult() |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @var array object graph as tree |
32 | 32 | */ |
33 | - private $_tree = array(); |
|
33 | + private $_tree=array(); |
|
34 | 34 | /** |
35 | 35 | * @var array tree node values |
36 | 36 | */ |
37 | - private $_entries = array(); |
|
37 | + private $_entries=array(); |
|
38 | 38 | /** |
39 | 39 | * @var array resulting object collection |
40 | 40 | */ |
41 | - private $_list = array(); |
|
41 | + private $_list=array(); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @return boolean true if the graph is empty |
45 | 45 | */ |
46 | 46 | public function isEmpty() |
47 | 47 | { |
48 | - return count($this->_entries) == 0; |
|
48 | + return count($this->_entries)==0; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -59,22 +59,22 @@ discard block |
||
59 | 59 | if(isset($this->_entries[$parent]) && ($this->_entries[$parent]!==null) |
60 | 60 | && isset($this->_entries[$node]) && ($this->_entries[$node]!==null)) |
61 | 61 | { |
62 | - $this->_entries[$node] = $object; |
|
62 | + $this->_entries[$node]=$object; |
|
63 | 63 | return; |
64 | 64 | } |
65 | - $this->_entries[$node] = $object; |
|
65 | + $this->_entries[$node]=$object; |
|
66 | 66 | if(empty($parent)) |
67 | 67 | { |
68 | 68 | if(isset($this->_entries[$node])) |
69 | 69 | return; |
70 | - $this->_tree[$node] = array(); |
|
70 | + $this->_tree[$node]=array(); |
|
71 | 71 | } |
72 | - $found = $this->addNode($this->_tree, $parent, $node); |
|
72 | + $found=$this->addNode($this->_tree, $parent, $node); |
|
73 | 73 | if(!$found && !empty($parent)) |
74 | 74 | { |
75 | - $this->_tree[$parent] = array(); |
|
76 | - if(!isset($this->_entries[$parent]) || $object !== '') |
|
77 | - $this->_entries[$parent] = $object; |
|
75 | + $this->_tree[$parent]=array(); |
|
76 | + if(!isset($this->_entries[$parent]) || $object!=='') |
|
77 | + $this->_entries[$parent]=$object; |
|
78 | 78 | $this->addNode($this->_tree, $parent, $node); |
79 | 79 | } |
80 | 80 | } |
@@ -88,20 +88,20 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function addNode(&$childs, $parent, $node) |
90 | 90 | { |
91 | - $found = false; |
|
91 | + $found=false; |
|
92 | 92 | reset($childs); |
93 | - for($i = 0, $k = count($childs); $i < $k; $i++) |
|
93 | + for($i=0, $k=count($childs); $i < $k; $i++) |
|
94 | 94 | { |
95 | - $key = key($childs); |
|
95 | + $key=key($childs); |
|
96 | 96 | next($childs); |
97 | - if($key == $parent) |
|
97 | + if($key==$parent) |
|
98 | 98 | { |
99 | - $found = true; |
|
100 | - $childs[$key][$node] = array(); |
|
99 | + $found=true; |
|
100 | + $childs[$key][$node]=array(); |
|
101 | 101 | } |
102 | 102 | else |
103 | 103 | { |
104 | - $found = $found || $this->addNode($childs[$key], $parent, $node); |
|
104 | + $found=$found || $this->addNode($childs[$key], $parent, $node); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | return $found; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function hasChildren(&$nodes) |
125 | 125 | { |
126 | - $hasChildren = false; |
|
126 | + $hasChildren=false; |
|
127 | 127 | foreach($nodes as $node) |
128 | - if(count($node) != 0) |
|
128 | + if(count($node)!=0) |
|
129 | 129 | return true; |
130 | 130 | return $hasChildren; |
131 | 131 | } |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function collectChildren($parent, &$nodes) |
139 | 139 | { |
140 | - $noChildren = !$this->hasChildren($nodes); |
|
141 | - $childs = array(); |
|
142 | - for(reset($nodes); $key = key($nodes);) |
|
140 | + $noChildren=!$this->hasChildren($nodes); |
|
141 | + $childs=array(); |
|
142 | + for(reset($nodes); $key=key($nodes);) |
|
143 | 143 | { |
144 | 144 | next($nodes); |
145 | 145 | if($noChildren) |
146 | 146 | { |
147 | - $childs[] = $key; |
|
147 | + $childs[]=$key; |
|
148 | 148 | unset($nodes[$key]); |
149 | 149 | } |
150 | 150 | else |
@@ -164,17 +164,17 @@ discard block |
||
164 | 164 | if(empty($parent) || empty($this->_entries[$parent])) |
165 | 165 | return; |
166 | 166 | |
167 | - $parentObject = $this->_entries[$parent]['object']; |
|
168 | - $property = $this->_entries[$nodes[0]]['property']; |
|
167 | + $parentObject=$this->_entries[$parent]['object']; |
|
168 | + $property=$this->_entries[$nodes[0]]['property']; |
|
169 | 169 | |
170 | - $list = TPropertyAccess::get($parentObject, $property); |
|
170 | + $list=TPropertyAccess::get($parentObject, $property); |
|
171 | 171 | |
172 | 172 | foreach($nodes as $node) |
173 | 173 | { |
174 | 174 | if($list instanceof TList) |
175 | - $parentObject->{$property}[] = $this->_entries[$node]['object']; |
|
175 | + $parentObject->{$property}[]=$this->_entries[$node]['object']; |
|
176 | 176 | else if(is_array($list)) |
177 | - $list[] = $this->_entries[$node]['object']; |
|
177 | + $list[]=$this->_entries[$node]['object']; |
|
178 | 178 | else |
179 | 179 | throw new TSqlMapExecutionException( |
180 | 180 | 'sqlmap_property_must_be_list'); |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | if(is_array($list)) |
184 | 184 | TPropertyAccess::set($parentObject, $property, $list); |
185 | 185 | |
186 | - if($this->_entries[$parent]['property'] === null) |
|
187 | - $this->_list[] = $parentObject; |
|
186 | + if($this->_entries[$parent]['property']===null) |
|
187 | + $this->_list[]=$parentObject; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | |
198 | 198 | public function __sleep() |
199 | 199 | { |
200 | - $exprops = array(); $cn = __CLASS__; |
|
201 | - if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; |
|
202 | - if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; |
|
203 | - if (!count($this->_list)) $exprops[] = "\0$cn\0_list"; |
|
204 | - return array_diff(parent::__sleep(),$exprops); |
|
200 | + $exprops=array(); $cn=__CLASS__; |
|
201 | + if(!count($this->_tree)) $exprops[]="\0$cn\0_tree"; |
|
202 | + if(!count($this->_entries)) $exprops[]="\0$cn\0_entries"; |
|
203 | + if(!count($this->_list)) $exprops[]="\0$cn\0_list"; |
|
204 | + return array_diff(parent::__sleep(), $exprops); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | \ No newline at end of file |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @var boolean true when data is mapped to a particular row. |
58 | 58 | */ |
59 | - private $_IsRowDataFound = false; |
|
59 | + private $_IsRowDataFound=false; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @var TSQLMapObjectCollectionTree group by object collection tree |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @var Post select is to query for list. |
68 | 68 | */ |
69 | - const QUERY_FOR_LIST = 0; |
|
69 | + const QUERY_FOR_LIST=0; |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @var Post select is to query for list. |
73 | 73 | */ |
74 | - const QUERY_FOR_ARRAY = 1; |
|
74 | + const QUERY_FOR_ARRAY=1; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @var Post select is to query for object. |
78 | 78 | */ |
79 | - const QUERY_FOR_OBJECT = 2; |
|
79 | + const QUERY_FOR_OBJECT=2; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return string Name used to identify the TMappedStatement amongst the others. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function initialGroupByResults() |
118 | 118 | { |
119 | - $this->_groupBy = new TSqlMapObjectCollectionTree(); |
|
119 | + $this->_groupBy=new TSqlMapObjectCollectionTree(); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function __construct(TSqlMapManager $sqlMap, TSqlMapStatement $statement) |
128 | 128 | { |
129 | - $this->_manager = $sqlMap; |
|
130 | - $this->_statement = $statement; |
|
131 | - $this->_command = new TPreparedCommand(); |
|
129 | + $this->_manager=$sqlMap; |
|
130 | + $this->_statement=$statement; |
|
131 | + $this->_command=new TPreparedCommand(); |
|
132 | 132 | $this->initialGroupByResults(); |
133 | 133 | } |
134 | 134 | |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | */ |
174 | 174 | protected function executeSQLQueryLimit($connection, $command, $max, $skip) |
175 | 175 | { |
176 | - if($max>-1 || $skip > -1) |
|
176 | + if($max > -1 || $skip > -1) |
|
177 | 177 | { |
178 | - $maxStr=$max>0?' LIMIT '.$max:''; |
|
179 | - $skipStr=$skip>0?' OFFSET '.$skip:''; |
|
178 | + $maxStr=$max > 0 ? ' LIMIT '.$max : ''; |
|
179 | + $skipStr=$skip > 0 ? ' OFFSET '.$skip : ''; |
|
180 | 180 | $command->setText($command->getText().$maxStr.$skipStr); |
181 | 181 | } |
182 | 182 | $connection->setActive(true); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
215 | 215 | { |
216 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter,$skip,$max); |
|
216 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
217 | 217 | return $this->runQueryForList($connection, $parameter, $sql, $result, $delegate); |
218 | 218 | } |
219 | 219 | |
@@ -236,17 +236,16 @@ discard block |
||
236 | 236 | public function runQueryForList($connection, $parameter, $sql, $result, $delegate=null) |
237 | 237 | { |
238 | 238 | $registry=$this->getManager()->getTypeHandlers(); |
239 | - $list = $result instanceof \ArrayAccess ? $result : |
|
240 | - $this->_statement->createInstanceOfListClass($registry); |
|
239 | + $list=$result instanceof \ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry); |
|
241 | 240 | $connection->setActive(true); |
242 | - $reader = $sql->query(); |
|
241 | + $reader=$sql->query(); |
|
243 | 242 | //$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); |
244 | 243 | if($delegate!==null) |
245 | 244 | { |
246 | 245 | foreach($reader as $row) |
247 | 246 | { |
248 | - $obj = $this->applyResultMap($row); |
|
249 | - $param = new TResultSetListItemParameter($obj, $parameter, $list); |
|
247 | + $obj=$this->applyResultMap($row); |
|
248 | + $param=new TResultSetListItemParameter($obj, $parameter, $list); |
|
250 | 249 | $this->raiseRowDelegate($delegate, $param); |
251 | 250 | } |
252 | 251 | } |
@@ -256,13 +255,13 @@ discard block |
||
256 | 255 | foreach($reader as $row) |
257 | 256 | { |
258 | 257 | // var_dump($row); |
259 | - $list[] = $this->applyResultMap($row); |
|
258 | + $list[]=$this->applyResultMap($row); |
|
260 | 259 | } |
261 | 260 | } |
262 | 261 | |
263 | 262 | if(!$this->_groupBy->isEmpty()) |
264 | 263 | { |
265 | - $list = $this->_groupBy->collect(); |
|
264 | + $list=$this->_groupBy->collect(); |
|
266 | 265 | $this->initialGroupByResults(); |
267 | 266 | } |
268 | 267 | |
@@ -284,9 +283,9 @@ discard block |
||
284 | 283 | * @param callback row delegate handler |
285 | 284 | * @return array An array of object containing the rows keyed by keyProperty. |
286 | 285 | */ |
287 | - public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
286 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
288 | 287 | { |
289 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
288 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
290 | 289 | return $this->runQueryForMap($connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
291 | 290 | } |
292 | 291 | |
@@ -310,20 +309,19 @@ discard block |
||
310 | 309 | */ |
311 | 310 | public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty=null, $delegate=null) |
312 | 311 | { |
313 | - $map = array(); |
|
312 | + $map=array(); |
|
314 | 313 | //$recordSet = $this->executeSQLQuery($connection, $sql); |
315 | 314 | $connection->setActive(true); |
316 | - $reader = $command->query(); |
|
315 | + $reader=$command->query(); |
|
317 | 316 | if($delegate!==null) |
318 | 317 | { |
319 | 318 | //while($row = $recordSet->fetchRow()) |
320 | 319 | foreach($reader as $row) |
321 | 320 | { |
322 | - $obj = $this->applyResultMap($row); |
|
323 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
324 | - $value = ($valueProperty===null) ? $obj : |
|
325 | - TPropertyAccess::get($obj, $valueProperty); |
|
326 | - $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
321 | + $obj=$this->applyResultMap($row); |
|
322 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
323 | + $value=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
324 | + $param=new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
327 | 325 | $this->raiseRowDelegate($delegate, $param); |
328 | 326 | } |
329 | 327 | } |
@@ -332,10 +330,9 @@ discard block |
||
332 | 330 | //while($row = $recordSet->fetchRow()) |
333 | 331 | foreach($reader as $row) |
334 | 332 | { |
335 | - $obj = $this->applyResultMap($row); |
|
336 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
337 | - $map[$key] = ($valueProperty===null) ? $obj : |
|
338 | - TPropertyAccess::get($obj, $valueProperty); |
|
333 | + $obj=$this->applyResultMap($row); |
|
334 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
335 | + $map[$key]=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
339 | 336 | } |
340 | 337 | } |
341 | 338 | $this->onExecuteQuery($command); |
@@ -352,22 +349,22 @@ discard block |
||
352 | 349 | { |
353 | 350 | if(is_string($handler)) |
354 | 351 | { |
355 | - call_user_func($handler,$this,$param); |
|
352 | + call_user_func($handler, $this, $param); |
|
356 | 353 | } |
357 | - else if(is_callable($handler,true)) |
|
354 | + else if(is_callable($handler, true)) |
|
358 | 355 | { |
359 | 356 | // an array: 0 - object, 1 - method name/path |
360 | - list($object,$method)=$handler; |
|
357 | + list($object, $method)=$handler; |
|
361 | 358 | if(is_string($object)) // static method call |
362 | - call_user_func($handler,$this,$param); |
|
359 | + call_user_func($handler, $this, $param); |
|
363 | 360 | else |
364 | 361 | { |
365 | - if(($pos=strrpos($method,'.'))!==false) |
|
362 | + if(($pos=strrpos($method, '.'))!==false) |
|
366 | 363 | { |
367 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
368 | - $method=substr($method,$pos+1); |
|
364 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
365 | + $method=substr($method, $pos + 1); |
|
369 | 366 | } |
370 | - $object->$method($this,$param); |
|
367 | + $object->$method($this, $param); |
|
371 | 368 | } |
372 | 369 | } |
373 | 370 | else |
@@ -384,7 +381,7 @@ discard block |
||
384 | 381 | */ |
385 | 382 | public function executeQueryForObject($connection, $parameter, $result=null) |
386 | 383 | { |
387 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
384 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
388 | 385 | return $this->runQueryForObject($connection, $sql, $result); |
389 | 386 | } |
390 | 387 | |
@@ -403,16 +400,16 @@ discard block |
||
403 | 400 | */ |
404 | 401 | public function runQueryForObject($connection, $command, &$result) |
405 | 402 | { |
406 | - $object = null; |
|
403 | + $object=null; |
|
407 | 404 | $connection->setActive(true); |
408 | 405 | foreach($command->query() as $row) |
409 | - $object = $this->applyResultMap($row, $result); |
|
406 | + $object=$this->applyResultMap($row, $result); |
|
410 | 407 | |
411 | 408 | if(!$this->_groupBy->isEmpty()) |
412 | 409 | { |
413 | - $list = $this->_groupBy->collect(); |
|
410 | + $list=$this->_groupBy->collect(); |
|
414 | 411 | $this->initialGroupByResults(); |
415 | - $object = $list[0]; |
|
412 | + $object=$list[0]; |
|
416 | 413 | } |
417 | 414 | |
418 | 415 | $this->executePostSelect($connection); |
@@ -430,14 +427,14 @@ discard block |
||
430 | 427 | */ |
431 | 428 | public function executeInsert($connection, $parameter) |
432 | 429 | { |
433 | - $generatedKey = $this->getPreGeneratedSelectKey($connection, $parameter); |
|
430 | + $generatedKey=$this->getPreGeneratedSelectKey($connection, $parameter); |
|
434 | 431 | |
435 | - $command = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
432 | + $command=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
436 | 433 | // var_dump($command,$parameter); |
437 | - $result = $command->execute(); |
|
434 | + $result=$command->execute(); |
|
438 | 435 | |
439 | 436 | if($generatedKey===null) |
440 | - $generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter); |
|
437 | + $generatedKey=$this->getPostGeneratedSelectKey($connection, $parameter); |
|
441 | 438 | |
442 | 439 | $this->executePostSelect($connection); |
443 | 440 | $this->onExecuteQuery($command); |
@@ -454,7 +451,7 @@ discard block |
||
454 | 451 | { |
455 | 452 | if($this->_statement instanceof TSqlMapInsert) |
456 | 453 | { |
457 | - $selectKey = $this->_statement->getSelectKey(); |
|
454 | + $selectKey=$this->_statement->getSelectKey(); |
|
458 | 455 | if(($selectKey!==null) && !$selectKey->getIsAfter()) |
459 | 456 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
460 | 457 | } |
@@ -470,7 +467,7 @@ discard block |
||
470 | 467 | { |
471 | 468 | if($this->_statement instanceof TSqlMapInsert) |
472 | 469 | { |
473 | - $selectKey = $this->_statement->getSelectKey(); |
|
470 | + $selectKey=$this->_statement->getSelectKey(); |
|
474 | 471 | if(($selectKey!==null) && $selectKey->getIsAfter()) |
475 | 472 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
476 | 473 | } |
@@ -485,10 +482,10 @@ discard block |
||
485 | 482 | */ |
486 | 483 | protected function executeSelectKey($connection, $parameter, $selectKey) |
487 | 484 | { |
488 | - $mappedStatement = $this->getManager()->getMappedStatement($selectKey->getID()); |
|
489 | - $generatedKey = $mappedStatement->executeQueryForObject( |
|
485 | + $mappedStatement=$this->getManager()->getMappedStatement($selectKey->getID()); |
|
486 | + $generatedKey=$mappedStatement->executeQueryForObject( |
|
490 | 487 | $connection, $parameter, null); |
491 | - if(strlen($prop = $selectKey->getProperty()) > 0) |
|
488 | + if(strlen($prop=$selectKey->getProperty()) > 0) |
|
492 | 489 | TPropertyAccess::set($parameter, $prop, $generatedKey); |
493 | 490 | return $generatedKey; |
494 | 491 | } |
@@ -502,8 +499,8 @@ discard block |
||
502 | 499 | */ |
503 | 500 | public function executeUpdate($connection, $parameter) |
504 | 501 | { |
505 | - $sql = $this->_command->create($this->getManager(),$connection, $this->_statement, $parameter); |
|
506 | - $affectedRows = $sql->execute(); |
|
502 | + $sql=$this->_command->create($this->getManager(), $connection, $this->_statement, $parameter); |
|
503 | + $affectedRows=$sql->execute(); |
|
507 | 504 | //$this->executeSQLQuery($connection, $sql); |
508 | 505 | $this->executePostSelect($connection); |
509 | 506 | $this->onExecuteQuery($sql); |
@@ -518,24 +515,24 @@ discard block |
||
518 | 515 | { |
519 | 516 | while(count($this->_selectQueue)) |
520 | 517 | { |
521 | - $postSelect = array_shift($this->_selectQueue); |
|
522 | - $method = $postSelect->getMethod(); |
|
523 | - $statement = $postSelect->getStatement(); |
|
524 | - $property = $postSelect->getResultProperty()->getProperty(); |
|
525 | - $keys = $postSelect->getKeys(); |
|
526 | - $resultObject = $postSelect->getResultObject(); |
|
527 | - |
|
528 | - if($method == self::QUERY_FOR_LIST || $method == self::QUERY_FOR_ARRAY) |
|
518 | + $postSelect=array_shift($this->_selectQueue); |
|
519 | + $method=$postSelect->getMethod(); |
|
520 | + $statement=$postSelect->getStatement(); |
|
521 | + $property=$postSelect->getResultProperty()->getProperty(); |
|
522 | + $keys=$postSelect->getKeys(); |
|
523 | + $resultObject=$postSelect->getResultObject(); |
|
524 | + |
|
525 | + if($method==self::QUERY_FOR_LIST || $method==self::QUERY_FOR_ARRAY) |
|
529 | 526 | { |
530 | - $values = $statement->executeQueryForList($connection, $keys, null); |
|
527 | + $values=$statement->executeQueryForList($connection, $keys, null); |
|
531 | 528 | |
532 | - if($method == self::QUERY_FOR_ARRAY) |
|
533 | - $values = $values->toArray(); |
|
529 | + if($method==self::QUERY_FOR_ARRAY) |
|
530 | + $values=$values->toArray(); |
|
534 | 531 | TPropertyAccess::set($resultObject, $property, $values); |
535 | 532 | } |
536 | - else if($method == self::QUERY_FOR_OBJECT) |
|
533 | + else if($method==self::QUERY_FOR_OBJECT) |
|
537 | 534 | { |
538 | - $value = $statement->executeQueryForObject($connection, $keys, null); |
|
535 | + $value=$statement->executeQueryForObject($connection, $keys, null); |
|
539 | 536 | TPropertyAccess::set($resultObject, $property, $value); |
540 | 537 | } |
541 | 538 | } |
@@ -558,21 +555,21 @@ discard block |
||
558 | 555 | */ |
559 | 556 | protected function applyResultMap($row, &$resultObject=null) |
560 | 557 | { |
561 | - if($row === false) return null; |
|
558 | + if($row===false) return null; |
|
562 | 559 | |
563 | - $resultMapName = $this->_statement->getResultMap(); |
|
564 | - $resultClass = $this->_statement->getResultClass(); |
|
560 | + $resultMapName=$this->_statement->getResultMap(); |
|
561 | + $resultClass=$this->_statement->getResultClass(); |
|
565 | 562 | |
566 | 563 | $obj=null; |
567 | 564 | if($this->getManager()->getResultMaps()->contains($resultMapName)) |
568 | - $obj = $this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
565 | + $obj=$this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
569 | 566 | else if(strlen($resultClass) > 0) |
570 | - $obj = $this->fillResultClass($resultClass, $row, $resultObject); |
|
567 | + $obj=$this->fillResultClass($resultClass, $row, $resultObject); |
|
571 | 568 | else |
572 | - $obj = $this->fillDefaultResultMap(null, $row, $resultObject); |
|
573 | - if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord) |
|
569 | + $obj=$this->fillDefaultResultMap(null, $row, $resultObject); |
|
570 | + if(class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord) |
|
574 | 571 | //Create a new clean active record. |
575 | - $obj=TActiveRecord::createRecord(get_class($obj),$obj); |
|
572 | + $obj=TActiveRecord::createRecord(get_class($obj), $obj); |
|
576 | 573 | return $obj; |
577 | 574 | } |
578 | 575 | |
@@ -587,8 +584,8 @@ discard block |
||
587 | 584 | { |
588 | 585 | if($resultObject===null) |
589 | 586 | { |
590 | - $registry = $this->getManager()->getTypeHandlers(); |
|
591 | - $resultObject = $this->_statement->createInstanceOfResultClass($registry,$row); |
|
587 | + $registry=$this->getManager()->getTypeHandlers(); |
|
588 | + $resultObject=$this->_statement->createInstanceOfResultClass($registry, $row); |
|
592 | 589 | } |
593 | 590 | |
594 | 591 | if($resultObject instanceOf \ArrayAccess) |
@@ -609,10 +606,10 @@ discard block |
||
609 | 606 | { |
610 | 607 | if($resultObject instanceof TList) |
611 | 608 | foreach($row as $v) |
612 | - $resultObject[] = $v; |
|
609 | + $resultObject[]=$v; |
|
613 | 610 | else |
614 | 611 | foreach($row as $k => $v) |
615 | - $resultObject[$k] = $v; |
|
612 | + $resultObject[$k]=$v; |
|
616 | 613 | return $resultObject; |
617 | 614 | } |
618 | 615 | |
@@ -624,18 +621,18 @@ discard block |
||
624 | 621 | */ |
625 | 622 | protected function fillResultObjectProperty($row, $resultObject) |
626 | 623 | { |
627 | - $index = 0; |
|
624 | + $index=0; |
|
628 | 625 | $registry=$this->getManager()->getTypeHandlers(); |
629 | 626 | foreach($row as $k=>$v) |
630 | 627 | { |
631 | - $property = new TResultProperty; |
|
628 | + $property=new TResultProperty; |
|
632 | 629 | if(is_string($k) && strlen($k) > 0) |
633 | 630 | $property->setColumn($k); |
634 | 631 | $property->setColumnIndex(++$index); |
635 | - $type = gettype(TPropertyAccess::get($resultObject,$k)); |
|
632 | + $type=gettype(TPropertyAccess::get($resultObject, $k)); |
|
636 | 633 | $property->setType($type); |
637 | - $value = $property->getPropertyValue($registry,$row); |
|
638 | - TPropertyAccess::set($resultObject, $k,$value); |
|
634 | + $value=$property->getPropertyValue($registry, $row); |
|
635 | + TPropertyAccess::set($resultObject, $k, $value); |
|
639 | 636 | } |
640 | 637 | return $resultObject; |
641 | 638 | } |
@@ -649,12 +646,12 @@ discard block |
||
649 | 646 | */ |
650 | 647 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
651 | 648 | { |
652 | - $resultMap = $this->getManager()->getResultMap($resultMapName); |
|
653 | - $registry = $this->getManager()->getTypeHandlers(); |
|
654 | - $resultMap = $resultMap->resolveSubMap($registry,$row); |
|
649 | + $resultMap=$this->getManager()->getResultMap($resultMapName); |
|
650 | + $registry=$this->getManager()->getTypeHandlers(); |
|
651 | + $resultMap=$resultMap->resolveSubMap($registry, $row); |
|
655 | 652 | |
656 | 653 | if($resultObject===null) |
657 | - $resultObject = $resultMap->createInstanceOfResult($registry); |
|
654 | + $resultObject=$resultMap->createInstanceOfResult($registry); |
|
658 | 655 | |
659 | 656 | if(is_object($resultObject)) |
660 | 657 | { |
@@ -666,7 +663,7 @@ discard block |
||
666 | 663 | } |
667 | 664 | else |
668 | 665 | { |
669 | - $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
666 | + $resultObject=$this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
670 | 667 | } |
671 | 668 | return $resultObject; |
672 | 669 | } |
@@ -681,11 +678,11 @@ discard block |
||
681 | 678 | */ |
682 | 679 | protected function addResultMapGroupBy($resultMap, $row, $parent, &$resultObject) |
683 | 680 | { |
684 | - $group = $this->getResultMapGroupKey($resultMap, $row); |
|
681 | + $group=$this->getResultMapGroupKey($resultMap, $row); |
|
685 | 682 | |
686 | 683 | if(empty($parent)) |
687 | 684 | { |
688 | - $rootObject = array('object'=>$resultObject, 'property' => null); |
|
685 | + $rootObject=array('object'=>$resultObject, 'property' => null); |
|
689 | 686 | $this->_groupBy->add(null, $group, $rootObject); |
690 | 687 | } |
691 | 688 | |
@@ -693,23 +690,23 @@ discard block |
||
693 | 690 | { |
694 | 691 | //set properties. |
695 | 692 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
696 | - $nested = $property->getResultMapping(); |
|
693 | + $nested=$property->getResultMapping(); |
|
697 | 694 | |
698 | 695 | //nested property |
699 | 696 | if($this->getManager()->getResultMaps()->contains($nested)) |
700 | 697 | { |
701 | - $nestedMap = $this->getManager()->getResultMap($nested); |
|
702 | - $groupKey = $this->getResultMapGroupKey($nestedMap, $row); |
|
698 | + $nestedMap=$this->getManager()->getResultMap($nested); |
|
699 | + $groupKey=$this->getResultMapGroupKey($nestedMap, $row); |
|
703 | 700 | |
704 | 701 | //add the node reference first |
705 | 702 | if(empty($parent)) |
706 | 703 | $this->_groupBy->add($group, $groupKey, ''); |
707 | 704 | |
708 | 705 | //get the nested result mapping value |
709 | - $value = $this->fillResultMap($nested, $row, $groupKey); |
|
706 | + $value=$this->fillResultMap($nested, $row, $groupKey); |
|
710 | 707 | |
711 | 708 | //add it to the object tree graph |
712 | - $groupObject = array('object'=>$value, 'property' => $property->getProperty()); |
|
709 | + $groupObject=array('object'=>$value, 'property' => $property->getProperty()); |
|
713 | 710 | if(empty($parent)) |
714 | 711 | $this->_groupBy->add($group, $groupKey, $groupObject); |
715 | 712 | else |
@@ -727,7 +724,7 @@ discard block |
||
727 | 724 | */ |
728 | 725 | protected function getResultMapGroupKey($resultMap, $row) |
729 | 726 | { |
730 | - $groupBy = $resultMap->getGroupBy(); |
|
727 | + $groupBy=$resultMap->getGroupBy(); |
|
731 | 728 | if(isset($row[$groupBy])) |
732 | 729 | return $resultMap->getID().$row[$groupBy]; |
733 | 730 | else |
@@ -748,12 +745,12 @@ discard block |
||
748 | 745 | $resultObject=''; |
749 | 746 | |
750 | 747 | if($resultMap!==null) |
751 | - $result = $this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
748 | + $result=$this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
752 | 749 | else |
753 | - $result = $row; |
|
750 | + $result=$row; |
|
754 | 751 | |
755 | 752 | //if scalar result types |
756 | - if(count($result) == 1 && ($type = gettype($resultObject))!= 'array') |
|
753 | + if(count($result)==1 && ($type=gettype($resultObject))!='array') |
|
757 | 754 | return $this->getScalarResult($result, $type); |
758 | 755 | else |
759 | 756 | return $result; |
@@ -768,14 +765,14 @@ discard block |
||
768 | 765 | */ |
769 | 766 | protected function fillArrayResultMap($resultMap, $row, $resultObject) |
770 | 767 | { |
771 | - $result = array(); |
|
768 | + $result=array(); |
|
772 | 769 | $registry=$this->getManager()->getTypeHandlers(); |
773 | 770 | foreach($resultMap->getColumns() as $column) |
774 | 771 | { |
775 | 772 | if(($column->getType()===null) |
776 | 773 | && ($resultObject!==null) && !is_object($resultObject)) |
777 | 774 | $column->setType(gettype($resultObject)); |
778 | - $result[$column->getProperty()] = $column->getPropertyValue($registry,$row); |
|
775 | + $result[$column->getProperty()]=$column->getPropertyValue($registry, $row); |
|
779 | 776 | } |
780 | 777 | return $result; |
781 | 778 | } |
@@ -788,7 +785,7 @@ discard block |
||
788 | 785 | */ |
789 | 786 | protected function getScalarResult($result, $type) |
790 | 787 | { |
791 | - $scalar = array_shift($result); |
|
788 | + $scalar=array_shift($result); |
|
792 | 789 | settype($scalar, $type); |
793 | 790 | return $scalar; |
794 | 791 | } |
@@ -802,23 +799,23 @@ discard block |
||
802 | 799 | */ |
803 | 800 | protected function setObjectProperty($resultMap, $property, $row, &$resultObject) |
804 | 801 | { |
805 | - $select = $property->getSelect(); |
|
806 | - $key = $property->getProperty(); |
|
807 | - $nested = $property->getNestedResultMap(); |
|
802 | + $select=$property->getSelect(); |
|
803 | + $key=$property->getProperty(); |
|
804 | + $nested=$property->getNestedResultMap(); |
|
808 | 805 | $registry=$this->getManager()->getTypeHandlers(); |
809 | - if($key === '') |
|
806 | + if($key==='') |
|
810 | 807 | { |
811 | - $resultObject = $property->getPropertyValue($registry,$row); |
|
808 | + $resultObject=$property->getPropertyValue($registry, $row); |
|
812 | 809 | } |
813 | - else if(strlen($select) == 0 && ($nested===null)) |
|
810 | + else if(strlen($select)==0 && ($nested===null)) |
|
814 | 811 | { |
815 | - $value = $property->getPropertyValue($registry,$row); |
|
812 | + $value=$property->getPropertyValue($registry, $row); |
|
816 | 813 | |
817 | - $this->_IsRowDataFound = $this->_IsRowDataFound || ($value != null); |
|
814 | + $this->_IsRowDataFound=$this->_IsRowDataFound || ($value!=null); |
|
818 | 815 | if(is_array($resultObject) || is_object($resultObject)) |
819 | 816 | TPropertyAccess::set($resultObject, $key, $value); |
820 | 817 | else |
821 | - $resultObject = $value; |
|
818 | + $resultObject=$value; |
|
822 | 819 | } |
823 | 820 | else if($nested!==null) |
824 | 821 | { |
@@ -831,9 +828,9 @@ discard block |
||
831 | 828 | } |
832 | 829 | else |
833 | 830 | { |
834 | - $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
835 | - if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
|
836 | - $obj = null; |
|
831 | + $obj=$nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
832 | + if($this->fillPropertyWithResultMap($nested, $row, $obj)==false) |
|
833 | + $obj=null; |
|
837 | 834 | TPropertyAccess::set($resultObject, $key, $obj); |
838 | 835 | } |
839 | 836 | } |
@@ -853,9 +850,9 @@ discard block |
||
853 | 850 | */ |
854 | 851 | protected function enquequePostSelect($select, $resultMap, $property, $row, $resultObject) |
855 | 852 | { |
856 | - $statement = $this->getManager()->getMappedStatement($select); |
|
857 | - $key = $this->getPostSelectKeys($resultMap, $property, $row); |
|
858 | - $postSelect = new TPostSelectBinding; |
|
853 | + $statement=$this->getManager()->getMappedStatement($select); |
|
854 | + $key=$this->getPostSelectKeys($resultMap, $property, $row); |
|
855 | + $postSelect=new TPostSelectBinding; |
|
859 | 856 | $postSelect->setStatement($statement); |
860 | 857 | $postSelect->setResultObject($resultObject); |
861 | 858 | $postSelect->setResultProperty($property); |
@@ -863,10 +860,10 @@ discard block |
||
863 | 860 | |
864 | 861 | if($property->instanceOfListType($resultObject)) |
865 | 862 | { |
866 | - $values = null; |
|
863 | + $values=null; |
|
867 | 864 | if($property->getLazyLoad()) |
868 | 865 | { |
869 | - $values = TLazyLoadList::newInstance($statement, $key, |
|
866 | + $values=TLazyLoadList::newInstance($statement, $key, |
|
870 | 867 | $resultObject, $property->getProperty()); |
871 | 868 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
872 | 869 | } |
@@ -879,7 +876,7 @@ discard block |
||
879 | 876 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
880 | 877 | |
881 | 878 | if(!$property->getLazyLoad()) |
882 | - $this->_selectQueue[] = $postSelect; |
|
879 | + $this->_selectQueue[]=$postSelect; |
|
883 | 880 | } |
884 | 881 | |
885 | 882 | /** |
@@ -889,23 +886,23 @@ discard block |
||
889 | 886 | * @param array current row data. |
890 | 887 | * @return array list of primary key values. |
891 | 888 | */ |
892 | - protected function getPostSelectKeys($resultMap, $property,$row) |
|
889 | + protected function getPostSelectKeys($resultMap, $property, $row) |
|
893 | 890 | { |
894 | - $value = $property->getColumn(); |
|
895 | - if(is_int(strpos($value.',',0)) || is_int(strpos($value, '=',0))) |
|
891 | + $value=$property->getColumn(); |
|
892 | + if(is_int(strpos($value.',', 0)) || is_int(strpos($value, '=', 0))) |
|
896 | 893 | { |
897 | - $keys = array(); |
|
894 | + $keys=array(); |
|
898 | 895 | foreach(explode(',', $value) as $entry) |
899 | 896 | { |
900 | - $pair =explode('=',$entry); |
|
901 | - $keys[trim($pair[0])] = $row[trim($pair[1])]; |
|
897 | + $pair=explode('=', $entry); |
|
898 | + $keys[trim($pair[0])]=$row[trim($pair[1])]; |
|
902 | 899 | } |
903 | 900 | return $keys; |
904 | 901 | } |
905 | 902 | else |
906 | 903 | { |
907 | 904 | $registry=$this->getManager()->getTypeHandlers(); |
908 | - return $property->getPropertyValue($registry,$row); |
|
905 | + return $property->getPropertyValue($registry, $row); |
|
909 | 906 | } |
910 | 907 | } |
911 | 908 | |
@@ -918,28 +915,28 @@ discard block |
||
918 | 915 | */ |
919 | 916 | protected function fillPropertyWithResultMap($resultMap, $row, &$resultObject) |
920 | 917 | { |
921 | - $dataFound = false; |
|
918 | + $dataFound=false; |
|
922 | 919 | foreach($resultMap->getColumns() as $property) |
923 | 920 | { |
924 | - $this->_IsRowDataFound = false; |
|
921 | + $this->_IsRowDataFound=false; |
|
925 | 922 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
926 | - $dataFound = $dataFound || $this->_IsRowDataFound; |
|
923 | + $dataFound=$dataFound || $this->_IsRowDataFound; |
|
927 | 924 | } |
928 | - $this->_IsRowDataFound = $dataFound; |
|
925 | + $this->_IsRowDataFound=$dataFound; |
|
929 | 926 | return $dataFound; |
930 | 927 | } |
931 | 928 | |
932 | 929 | public function __wakeup() |
933 | 930 | { |
934 | - if (is_null($this->_selectQueue)) $this->_selectQueue = array(); |
|
931 | + if(is_null($this->_selectQueue)) $this->_selectQueue=array(); |
|
935 | 932 | } |
936 | 933 | |
937 | 934 | public function __sleep() |
938 | 935 | { |
939 | - $exprops = array(); $cn = __CLASS__; |
|
940 | - if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; |
|
941 | - if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy"; |
|
942 | - if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; |
|
943 | - return array_diff(parent::__sleep(),$exprops); |
|
936 | + $exprops=array(); $cn=__CLASS__; |
|
937 | + if(!count($this->_selectQueue)) $exprops[]="\0$cn\0_selectQueue"; |
|
938 | + if(is_null($this->_groupBy)) $exprops[]="\0$cn\0_groupBy"; |
|
939 | + if(!$this->_IsRowDataFound) $exprops[]="\0$cn\0_IsRowDataFound"; |
|
940 | + return array_diff(parent::__sleep(), $exprops); |
|
944 | 941 | } |
945 | 942 | } |
946 | 943 | \ No newline at end of file |
@@ -26,18 +26,18 @@ |
||
26 | 26 | private $_keys=null; |
27 | 27 | private $_method=TMappedStatement::QUERY_FOR_LIST; |
28 | 28 | |
29 | - public function getStatement(){ return $this->_statement; } |
|
30 | - public function setStatement($value){ $this->_statement = $value; } |
|
29 | + public function getStatement() { return $this->_statement; } |
|
30 | + public function setStatement($value) { $this->_statement=$value; } |
|
31 | 31 | |
32 | - public function getResultProperty(){ return $this->_property; } |
|
33 | - public function setResultProperty($value){ $this->_property = $value; } |
|
32 | + public function getResultProperty() { return $this->_property; } |
|
33 | + public function setResultProperty($value) { $this->_property=$value; } |
|
34 | 34 | |
35 | - public function getResultObject(){ return $this->_resultObject; } |
|
36 | - public function setResultObject($value){ $this->_resultObject = $value; } |
|
35 | + public function getResultObject() { return $this->_resultObject; } |
|
36 | + public function setResultObject($value) { $this->_resultObject=$value; } |
|
37 | 37 | |
38 | - public function getKeys(){ return $this->_keys; } |
|
39 | - public function setKeys($value){ $this->_keys = $value; } |
|
38 | + public function getKeys() { return $this->_keys; } |
|
39 | + public function setKeys($value) { $this->_keys=$value; } |
|
40 | 40 | |
41 | - public function getMethod(){ return $this->_method; } |
|
42 | - public function setMethod($value){ $this->_method = $value; } |
|
41 | + public function getMethod() { return $this->_method; } |
|
42 | + public function setMethod($value) { $this->_method=$value; } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -27,10 +27,10 @@ |
||
27 | 27 | |
28 | 28 | public function __construct($key, $value, $parameter, &$map) |
29 | 29 | { |
30 | - $this->_key = $key; |
|
31 | - $this->_value = $value; |
|
32 | - $this->_parameterObject = $parameter; |
|
33 | - $this->_map = &$map; |
|
30 | + $this->_key=$key; |
|
31 | + $this->_value=$value; |
|
32 | + $this->_parameterObject=$parameter; |
|
33 | + $this->_map=&$map; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function getKey() |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class TSqlMapSelectKey extends TSqlMapStatement |
24 | 24 | { |
25 | - private $_type = 'post'; |
|
25 | + private $_type='post'; |
|
26 | 26 | private $_property; |
27 | 27 | |
28 | 28 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function setType($value) |
40 | 40 | { |
41 | - $this->_type = strtolower($value) == 'post' ? 'post' : 'pre'; |
|
41 | + $this->_type=strtolower($value)=='post' ? 'post' : 'pre'; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function setProperty($value) |
56 | 56 | { |
57 | - $this->_property = $value; |
|
57 | + $this->_property=$value; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -70,6 +70,6 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getIsAfter() |
72 | 72 | { |
73 | - return $this->_type == 'post'; |
|
73 | + return $this->_type=='post'; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function setValue($value) |
43 | 43 | { |
44 | - $this->_value = $value; |
|
44 | + $this->_value=$value; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -58,6 +58,6 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setResultMapping($value) |
60 | 60 | { |
61 | - $this->_resultMapping = $value; |
|
61 | + $this->_resultMapping=$value; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | \ No newline at end of file |