@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | protected function getRecordTableName(TActiveRecord $record) |
73 | 73 | { |
74 | 74 | $class = new ReflectionClass($record); |
75 | - if ($class->hasConstant(self::TABLE_CONST)) { |
|
75 | + if($class->hasConstant(self::TABLE_CONST)) { |
|
76 | 76 | $value = $class->getConstant(self::TABLE_CONST); |
77 | - if (empty($value)) { |
|
77 | + if(empty($value)) { |
|
78 | 78 | throw new TActiveRecordException( |
79 | 79 | 'ar_invalid_tablename_property', |
80 | 80 | get_class($record), |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | ); |
83 | 83 | } |
84 | 84 | return $value; |
85 | - } elseif ($class->hasMethod(self::TABLE_METHOD)) { |
|
85 | + } elseif($class->hasMethod(self::TABLE_METHOD)) { |
|
86 | 86 | $value = $record->{self::TABLE_METHOD}(); |
87 | - if (empty($value)) { |
|
87 | + if(empty($value)) { |
|
88 | 88 | throw new TActiveRecordException( |
89 | 89 | 'ar_invalid_tablename_method', |
90 | 90 | get_class($record), |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | { |
119 | 119 | $connStr = $connection->getConnectionString(); |
120 | 120 | $key = $connStr . $tableName; |
121 | - if (!isset($this->_tables[$key])) { |
|
121 | + if(!isset($this->_tables[$key])) { |
|
122 | 122 | //call this first to ensure that unserializing the cache |
123 | 123 | //will find the correct driver dependent classes. |
124 | - if (!isset($this->_meta[$connStr])) { |
|
124 | + if(!isset($this->_meta[$connStr])) { |
|
125 | 125 | $this->_meta[$connStr] = TDbMetaData::getInstance($connection); |
126 | 126 | } |
127 | 127 | |
128 | 128 | $tableInfo = null; |
129 | - if (($cache = $this->getManager()->getCache()) !== null) { |
|
129 | + if(($cache = $this->getManager()->getCache()) !== null) { |
|
130 | 130 | $tableInfo = $cache->get($key); |
131 | 131 | } |
132 | - if (empty($tableInfo)) { |
|
132 | + if(empty($tableInfo)) { |
|
133 | 133 | $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName); |
134 | - if ($cache !== null) { |
|
134 | + if($cache !== null) { |
|
135 | 135 | $cache->set($key, $tableInfo); |
136 | 136 | } |
137 | 137 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $conn = $record->getDbConnection(); |
150 | 150 | $connStr = $conn->getConnectionString(); |
151 | 151 | $tableInfo = $this->getRecordTableInfo($record); |
152 | - if (!isset($this->_commandBuilders[$connStr])) { |
|
152 | + if(!isset($this->_commandBuilders[$connStr])) { |
|
153 | 153 | $builder = $tableInfo->createCommandBuilder($record->getDbConnection()); |
154 | 154 | $command = new TDataGatewayCommand($builder); |
155 | 155 | $command->OnCreateCommand[] = [$this, 'onCreateCommand']; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | public function onCreateCommand($sender, $param) |
175 | 175 | { |
176 | 176 | $this->raiseEvent('OnCreateCommand', $this, $param); |
177 | - if ($this->_currentRecord !== null) { |
|
177 | + if($this->_currentRecord !== null) { |
|
178 | 178 | $this->_currentRecord->onCreateCommand($param); |
179 | 179 | } |
180 | 180 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | public function onExecuteCommand($sender, $param) |
194 | 194 | { |
195 | 195 | $this->raiseEvent('OnExecuteCommand', $this, $param); |
196 | - if ($this->_currentRecord !== null) { |
|
196 | + if($this->_currentRecord !== null) { |
|
197 | 197 | $this->_currentRecord->onExecuteCommand($param); |
198 | 198 | } |
199 | 199 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | { |
285 | 285 | //$this->updateAssociatedRecords($record,true); |
286 | 286 | $result = $this->getCommand($record)->insert($this->getInsertValues($record)); |
287 | - if ($result) { |
|
287 | + if($result) { |
|
288 | 288 | $this->updatePostInsert($record); |
289 | 289 | } |
290 | 290 | //$this->updateAssociatedRecords($record); |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | { |
300 | 300 | $command = $this->getCommand($record); |
301 | 301 | $tableInfo = $command->getTableInfo(); |
302 | - foreach ($tableInfo->getColumns() as $name => $column) { |
|
303 | - if ($column->hasSequence()) { |
|
302 | + foreach($tableInfo->getColumns() as $name => $column) { |
|
303 | + if($column->hasSequence()) { |
|
304 | 304 | $record->setColumnValue($name, $command->getLastInsertID($column->getSequenceName())); |
305 | 305 | } |
306 | 306 | } |
@@ -314,12 +314,12 @@ discard block |
||
314 | 314 | { |
315 | 315 | $values = []; |
316 | 316 | $tableInfo = $this->getCommand($record)->getTableInfo(); |
317 | - foreach ($tableInfo->getColumns() as $name => $column) { |
|
318 | - if ($column->getIsExcluded()) { |
|
317 | + foreach($tableInfo->getColumns() as $name => $column) { |
|
318 | + if($column->getIsExcluded()) { |
|
319 | 319 | continue; |
320 | 320 | } |
321 | 321 | $value = $record->getColumnValue($name); |
322 | - if (!$column->getAllowNull() && $value === null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) { |
|
322 | + if(!$column->getAllowNull() && $value === null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) { |
|
323 | 323 | throw new TActiveRecordException( |
324 | 324 | 'ar_value_must_not_be_null', |
325 | 325 | get_class($record), |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $name |
328 | 328 | ); |
329 | 329 | } |
330 | - if ($value !== null) { |
|
330 | + if($value !== null) { |
|
331 | 331 | $values[$name] = $value; |
332 | 332 | } |
333 | 333 | } |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | $values = []; |
354 | 354 | $tableInfo = $this->getCommand($record)->getTableInfo(); |
355 | 355 | $primary = []; |
356 | - foreach ($tableInfo->getColumns() as $name => $column) { |
|
357 | - if ($column->getIsExcluded()) { |
|
356 | + foreach($tableInfo->getColumns() as $name => $column) { |
|
357 | + if($column->getIsExcluded()) { |
|
358 | 358 | continue; |
359 | 359 | } |
360 | 360 | $value = $record->getColumnValue($name); |
361 | - if (!$column->getAllowNull() && $value === null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) { |
|
361 | + if(!$column->getAllowNull() && $value === null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) { |
|
362 | 362 | throw new TActiveRecordException( |
363 | 363 | 'ar_value_must_not_be_null', |
364 | 364 | get_class($record), |
@@ -366,13 +366,13 @@ discard block |
||
366 | 366 | $name |
367 | 367 | ); |
368 | 368 | } |
369 | - if ($column->getIsPrimaryKey()) { |
|
369 | + if($column->getIsPrimaryKey()) { |
|
370 | 370 | $primary[$name] = $value; |
371 | 371 | } else { |
372 | 372 | $values[$name] = $value; |
373 | 373 | } |
374 | 374 | } |
375 | - return [$values,$primary]; |
|
375 | + return [$values, $primary]; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo = false) |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | { |
396 | 396 | $tableInfo = $this->getCommand($record)->getTableInfo(); |
397 | 397 | $primary = []; |
398 | - foreach ($tableInfo->getColumns() as $name => $column) { |
|
399 | - if ($column->getIsPrimaryKey()) { |
|
398 | + foreach($tableInfo->getColumns() as $name => $column) { |
|
399 | + if($column->getIsPrimaryKey()) { |
|
400 | 400 | $primary[$name] = $record->getColumnValue($name); |
401 | 401 | } |
402 | 402 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | protected function raiseCommandEvent($event, $command, $record, $criteria) |
435 | 435 | { |
436 | - if (!($criteria instanceof TSqlCriteria)) { |
|
436 | + if(!($criteria instanceof TSqlCriteria)) { |
|
437 | 437 | $criteria = new TActiveRecordCriteria(null, $criteria); |
438 | 438 | } |
439 | 439 | $param = new TActiveRecordEventParameter($command, $record, $criteria); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function commit() |
65 | 65 | { |
66 | - if ($this->_active && $this->_connection->getActive()) { |
|
66 | + if($this->_active && $this->_connection->getActive()) { |
|
67 | 67 | $this->_connection->getPdoInstance()->commit(); |
68 | 68 | $this->_active = false; |
69 | 69 | } else { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function rollback() |
79 | 79 | { |
80 | - if ($this->_active && $this->_connection->getActive()) { |
|
80 | + if($this->_active && $this->_connection->getActive()) { |
|
81 | 81 | $this->_connection->getPdoInstance()->rollBack(); |
82 | 82 | $this->_active = false; |
83 | 83 | } else { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | public function __sleep() |
141 | 141 | { |
142 | 142 | // $this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session |
143 | - return array_diff(parent::__sleep(), ["\0Prado\Data\TDbConnection\0_pdo","\0Prado\Data\TDbConnection\0_active"]); |
|
143 | + return array_diff(parent::__sleep(), ["\0Prado\Data\TDbConnection\0_pdo", "\0Prado\Data\TDbConnection\0_active"]); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | public function setActive($value) |
169 | 169 | { |
170 | 170 | $value = TPropertyValue::ensureBoolean($value); |
171 | - if ($value !== $this->_active) { |
|
172 | - if ($value) { |
|
171 | + if($value !== $this->_active) { |
|
172 | + if($value) { |
|
173 | 173 | $this->open(); |
174 | 174 | } else { |
175 | 175 | $this->close(); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function open() |
185 | 185 | { |
186 | - if ($this->_pdo === null) { |
|
186 | + if($this->_pdo === null) { |
|
187 | 187 | try { |
188 | 188 | $this->_pdo = new PDO( |
189 | 189 | $this->getConnectionString(), |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected function setConnectionCharset() |
222 | 222 | { |
223 | - if ($this->_charset === '' || $this->_active === false) { |
|
223 | + if($this->_charset === '' || $this->_active === false) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | - switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { |
|
226 | + switch($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { |
|
227 | 227 | case 'mysql': |
228 | 228 | case 'sqlite': |
229 | 229 | $stmt = $this->_pdo->prepare('SET NAMES ?'); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function createCommand($sql) |
321 | 321 | { |
322 | - if ($this->getActive()) { |
|
322 | + if($this->getActive()) { |
|
323 | 323 | return new TDbCommand($this, $sql); |
324 | 324 | } else { |
325 | 325 | throw new TDbException('dbconnection_connection_inactive'); |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function getCurrentTransaction() |
333 | 333 | { |
334 | - if ($this->_transaction !== null) { |
|
335 | - if ($this->_transaction->getActive()) { |
|
334 | + if($this->_transaction !== null) { |
|
335 | + if($this->_transaction->getActive()) { |
|
336 | 336 | return $this->_transaction; |
337 | 337 | } |
338 | 338 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function beginTransaction() |
348 | 348 | { |
349 | - if ($this->getActive()) { |
|
349 | + if($this->getActive()) { |
|
350 | 350 | $this->_pdo->beginTransaction(); |
351 | 351 | return $this->_transaction = Prado::createComponent($this->getTransactionClass(), $this); |
352 | 352 | } else { |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function setTransactionClass($value) |
372 | 372 | { |
373 | - $this->_transactionClass = (string)$value; |
|
373 | + $this->_transactionClass = (string) $value; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public function getLastInsertID($sequenceName = '') |
383 | 383 | { |
384 | - if ($this->getActive()) { |
|
384 | + if($this->getActive()) { |
|
385 | 385 | return $this->_pdo->lastInsertId($sequenceName); |
386 | 386 | } else { |
387 | 387 | throw new TDbException('dbconnection_connection_inactive'); |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function quoteString($str) |
398 | 398 | { |
399 | - if ($this->getActive()) { |
|
399 | + if($this->getActive()) { |
|
400 | 400 | return $this->_pdo->quote($str); |
401 | 401 | } else { |
402 | 402 | throw new TDbException('dbconnection_connection_inactive'); |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public function getDbMetaData() |
440 | 440 | { |
441 | - if ($this->_dbMeta === null) { |
|
441 | + if($this->_dbMeta === null) { |
|
442 | 442 | $this->_dbMeta = TDbMetaData::getInstance($this); |
443 | 443 | } |
444 | 444 | return $this->_dbMeta; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function getColumnCase() |
451 | 451 | { |
452 | - switch ($this->getAttribute(PDO::ATTR_CASE)) { |
|
452 | + switch($this->getAttribute(PDO::ATTR_CASE)) { |
|
453 | 453 | case PDO::CASE_NATURAL: |
454 | 454 | return TDbColumnCaseMode::Preserved; |
455 | 455 | case PDO::CASE_LOWER: |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | */ |
465 | 465 | public function setColumnCase($value) |
466 | 466 | { |
467 | - switch (TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbColumnCaseMode')) { |
|
467 | + switch(TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbColumnCaseMode')) { |
|
468 | 468 | case TDbColumnCaseMode::Preserved: |
469 | 469 | $value = PDO::CASE_NATURAL; |
470 | 470 | break; |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | public function getNullConversion() |
485 | 485 | { |
486 | - switch ($this->getAttribute(PDO::ATTR_ORACLE_NULLS)) { |
|
486 | + switch($this->getAttribute(PDO::ATTR_ORACLE_NULLS)) { |
|
487 | 487 | case PDO::NULL_NATURAL: |
488 | 488 | return TDbNullConversionMode::Preserved; |
489 | 489 | case PDO::NULL_EMPTY_STRING: |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | */ |
499 | 499 | public function setNullConversion($value) |
500 | 500 | { |
501 | - switch (TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbNullConversionMode')) { |
|
501 | + switch(TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbNullConversionMode')) { |
|
502 | 502 | case TDbNullConversionMode::Preserved: |
503 | 503 | $value = PDO::NULL_NATURAL; |
504 | 504 | break; |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public function getAttribute($name) |
615 | 615 | { |
616 | - if ($this->getActive()) { |
|
616 | + if($this->getActive()) { |
|
617 | 617 | return $this->_pdo->getAttribute($name); |
618 | 618 | } else { |
619 | 619 | throw new TDbException('dbconnection_connection_inactive'); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | */ |
629 | 629 | public function setAttribute($name, $value) |
630 | 630 | { |
631 | - if ($this->_pdo instanceof PDO) { |
|
631 | + if($this->_pdo instanceof PDO) { |
|
632 | 632 | $this->_pdo->setAttribute($name, $value); |
633 | 633 | } else { |
634 | 634 | $this->_attributes[$name] = $value; |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty = null, $skip = -1, $max = -1, $delegate = null) |
48 | 48 | { |
49 | 49 | $sql = $this->createCommand($connection, $parameter, $skip, $max); |
50 | - $key = $this->getCacheKey([clone($sql), $keyProperty, $valueProperty,$skip, $max]); |
|
50 | + $key = $this->getCacheKey([clone($sql), $keyProperty, $valueProperty, $skip, $max]); |
|
51 | 51 | $map = $this->getStatement()->getCache()->get($key); |
52 | - if ($map === null) { |
|
52 | + if($map === null) { |
|
53 | 53 | $map = $this->_mappedStatement->runQueryForMap( |
54 | 54 | $connection, |
55 | 55 | $parameter, |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $sql = $this->createCommand($connection, $parameter, $skip, $max); |
79 | 79 | $key = $this->getCacheKey([clone($sql), $parameter, $skip, $max]); |
80 | 80 | $list = $this->getStatement()->getCache()->get($key); |
81 | - if ($list === null) { |
|
81 | + if($list === null) { |
|
82 | 82 | $list = $this->_mappedStatement->runQueryForList( |
83 | 83 | $connection, |
84 | 84 | $parameter, |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $sql = $this->createCommand($connection, $parameter); |
97 | 97 | $key = $this->getCacheKey([clone($sql), $parameter]); |
98 | 98 | $object = $this->getStatement()->getCache()->get($key); |
99 | - if ($object === null) { |
|
99 | + if($object === null) { |
|
100 | 100 | $object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
101 | 101 | $this->getStatement()->getCache()->set($key, $object); |
102 | 102 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | $connection->setActive(true); |
34 | 34 | $sql = $prepared->getPreparedSql(); |
35 | 35 | |
36 | - if ($sqlText instanceof TSimpleDynamicSql) { |
|
36 | + if($sqlText instanceof TSimpleDynamicSql) { |
|
37 | 37 | $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
38 | 38 | } |
39 | 39 | |
40 | - if ($max !== null || $skip !== null) { |
|
40 | + if($max !== null || $skip !== null) { |
|
41 | 41 | $builder = TDbMetaData::getInstance($connection)->createCommandBuilder(); |
42 | 42 | $sql = $builder->applyLimitOffset($sql, $max, $skip); |
43 | 43 | } |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | $properties = $prepared->getParameterNames(false); |
53 | 53 | //$parameters = $prepared->getParameterValues(); |
54 | 54 | $registry = $manager->getTypeHandlers(); |
55 | - if ($properties) { |
|
56 | - for ($i = 0, $k = $properties->getCount(); $i < $k; $i++) { |
|
55 | + if($properties) { |
|
56 | + for($i = 0, $k = $properties->getCount(); $i < $k; $i++) { |
|
57 | 57 | $property = $statement->parameterMap()->getProperty($i); |
58 | 58 | $value = $statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject); |
59 | 59 | $dbType = $property->getDbType(); |
60 | - if ($dbType == '') { //relies on PHP lax comparison |
|
60 | + if($dbType == '') { //relies on PHP lax comparison |
|
61 | 61 | $command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value)); |
62 | - } elseif (strpos($dbType, 'PDO::') === 0) { |
|
62 | + } elseif(strpos($dbType, 'PDO::') === 0) { |
|
63 | 63 | $command->bindValue($i + 1, $value, constant($property->getDbType())); |
64 | 64 | } //assumes PDO types, e.g. PDO::PARAM_INT |
65 | 65 | else { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $this->_preparedStatement = new TPreparedStatement(); |
37 | 37 | $this->_preparedStatement->setPreparedSql($this->_commandText); |
38 | - if ($this->_statement->parameterMap() !== null) { |
|
38 | + if($this->_statement->parameterMap() !== null) { |
|
39 | 39 | $this->createParametersForTextCommand(); |
40 | 40 | } |
41 | 41 | return $this->_preparedStatement; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | protected function createParametersForTextCommand() |
45 | 45 | { |
46 | - foreach ($this->_statement->ParameterMap()->getProperties() as $prop) { |
|
46 | + foreach($this->_statement->ParameterMap()->getProperties() as $prop) { |
|
47 | 47 | $this->_preparedStatement->getParameterNames()->add($prop->getProperty()); |
48 | 48 | } |
49 | 49 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | public function replaceDynamicParameter($sql, $parameter) |
34 | 34 | { |
35 | - foreach ($this->_mappings as $property) { |
|
35 | + foreach($this->_mappings as $property) { |
|
36 | 36 | $value = TPropertyAccess::get($parameter, $property); |
37 | 37 | $sql = preg_replace('/' . TSimpleDynamicParser::DYNAMIC_TOKEN . '/', str_replace('$', '\$', $value), $sql, 1); |
38 | 38 | } |
@@ -57,22 +57,22 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function add($parent, $node, $object = '') |
59 | 59 | { |
60 | - if (isset($this->_entries[$parent]) && ($this->_entries[$parent] !== null) |
|
60 | + if(isset($this->_entries[$parent]) && ($this->_entries[$parent] !== null) |
|
61 | 61 | && isset($this->_entries[$node]) && ($this->_entries[$node] !== null)) { |
62 | 62 | $this->_entries[$node] = $object; |
63 | 63 | return; |
64 | 64 | } |
65 | 65 | $this->_entries[$node] = $object; |
66 | - if (empty($parent)) { |
|
67 | - if (isset($this->_entries[$node])) { |
|
66 | + if(empty($parent)) { |
|
67 | + if(isset($this->_entries[$node])) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | $this->_tree[$node] = []; |
71 | 71 | } |
72 | 72 | $found = $this->addNode($this->_tree, $parent, $node); |
73 | - if (!$found && !empty($parent)) { |
|
73 | + if(!$found && !empty($parent)) { |
|
74 | 74 | $this->_tree[$parent] = []; |
75 | - if (!isset($this->_entries[$parent]) || $object !== '') { |
|
75 | + if(!isset($this->_entries[$parent]) || $object !== '') { |
|
76 | 76 | $this->_entries[$parent] = $object; |
77 | 77 | } |
78 | 78 | $this->addNode($this->_tree, $parent, $node); |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | { |
91 | 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 | $key = key($childs); |
95 | 95 | next($childs); |
96 | - if ($key == $parent) { |
|
96 | + if($key == $parent) { |
|
97 | 97 | $found = true; |
98 | 98 | $childs[$key][$node] = []; |
99 | 99 | } else { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function collect() |
110 | 110 | { |
111 | - while (count($this->_tree) > 0) { |
|
111 | + while(count($this->_tree) > 0) { |
|
112 | 112 | $this->collectChildren(null, $this->_tree); |
113 | 113 | } |
114 | 114 | return $this->getCollection(); |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | protected function hasChildren(&$nodes) |
122 | 122 | { |
123 | 123 | $hasChildren = false; |
124 | - foreach ($nodes as $node) { |
|
125 | - if (count($node) != 0) { |
|
124 | + foreach($nodes as $node) { |
|
125 | + if(count($node) != 0) { |
|
126 | 126 | return true; |
127 | 127 | } |
128 | 128 | } |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | { |
139 | 139 | $noChildren = !$this->hasChildren($nodes); |
140 | 140 | $childs = []; |
141 | - for (reset($nodes); $key = key($nodes);) { |
|
141 | + for(reset($nodes); $key = key($nodes);) { |
|
142 | 142 | next($nodes); |
143 | - if ($noChildren) { |
|
143 | + if($noChildren) { |
|
144 | 144 | $childs[] = $key; |
145 | 145 | unset($nodes[$key]); |
146 | 146 | } else { |
147 | 147 | $this->collectChildren($key, $nodes[$key]); |
148 | 148 | } |
149 | 149 | } |
150 | - if (count($childs) > 0) { |
|
150 | + if(count($childs) > 0) { |
|
151 | 151 | $this->onChildNodesVisited($parent, $childs); |
152 | 152 | } |
153 | 153 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | protected function onChildNodesVisited($parent, $nodes) |
161 | 161 | { |
162 | - if (empty($parent) || empty($this->_entries[$parent])) { |
|
162 | + if(empty($parent) || empty($this->_entries[$parent])) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | |
169 | 169 | $list = TPropertyAccess::get($parentObject, $property); |
170 | 170 | |
171 | - foreach ($nodes as $node) { |
|
172 | - if ($list instanceof TList) { |
|
171 | + foreach($nodes as $node) { |
|
172 | + if($list instanceof TList) { |
|
173 | 173 | $parentObject->{$property}[] = $this->_entries[$node]['object']; |
174 | - } elseif (is_array($list)) { |
|
174 | + } elseif(is_array($list)) { |
|
175 | 175 | $list[] = $this->_entries[$node]['object']; |
176 | 176 | } else { |
177 | 177 | throw new TSqlMapExecutionException( |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - if (is_array($list)) { |
|
183 | + if(is_array($list)) { |
|
184 | 184 | TPropertyAccess::set($parentObject, $property, $list); |
185 | 185 | } |
186 | 186 | |
187 | - if ($this->_entries[$parent]['property'] === null) { |
|
187 | + if($this->_entries[$parent]['property'] === null) { |
|
188 | 188 | $this->_list[] = $parentObject; |
189 | 189 | } |
190 | 190 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | { |
202 | 202 | $exprops = []; |
203 | 203 | $cn = __CLASS__; |
204 | - if (!count($this->_tree)) { |
|
204 | + if(!count($this->_tree)) { |
|
205 | 205 | $exprops[] = "\0$cn\0_tree"; |
206 | 206 | } |
207 | - if (!count($this->_entries)) { |
|
207 | + if(!count($this->_entries)) { |
|
208 | 208 | $exprops[] = "\0$cn\0_entries"; |
209 | 209 | } |
210 | - if (!count($this->_list)) { |
|
210 | + if(!count($this->_list)) { |
|
211 | 211 | $exprops[] = "\0$cn\0_list"; |
212 | 212 | } |
213 | 213 | return array_diff(parent::__sleep(), $exprops); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | public function getParameterNames($needed = true) |
40 | 40 | { |
41 | - if (!$this->_parameterNames and $needed) { |
|
41 | + if(!$this->_parameterNames and $needed) { |
|
42 | 42 | $this->_parameterNames = new TList; |
43 | 43 | } |
44 | 44 | return $this->_parameterNames; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | public function getParameterValues($needed = true) |
53 | 53 | { |
54 | - if (!$this->_parameterValues and $needed) { |
|
54 | + if(!$this->_parameterValues and $needed) { |
|
55 | 55 | $this->_parameterValues = new TMap; |
56 | 56 | } |
57 | 57 | return $this->_parameterValues; |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | { |
67 | 67 | $exprops = []; |
68 | 68 | $cn = __CLASS__; |
69 | - if (!$this->_parameterNames or !$this->_parameterNames->getCount()) { |
|
69 | + if(!$this->_parameterNames or !$this->_parameterNames->getCount()) { |
|
70 | 70 | $exprops[] = "\0$cn\0_parameterNames"; |
71 | 71 | } |
72 | - if (!$this->_parameterValues or !$this->_parameterValues->getCount()) { |
|
72 | + if(!$this->_parameterValues or !$this->_parameterValues->getCount()) { |
|
73 | 73 | $exprops[] = "\0$cn\0_parameterValues"; |
74 | 74 | } |
75 | 75 | return array_diff(parent::__sleep(), $exprops); |