@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param string $table_name |
110 | 110 | * @param mixed $id |
111 | 111 | */ |
112 | - public function __construct(TDBMService $tdbmService, $table_name, $id=false) { |
|
112 | + public function __construct(TDBMService $tdbmService, $table_name, $id = false) { |
|
113 | 113 | $this->tdbmService = $tdbmService; |
114 | 114 | $this->db_connection = $this->tdbmService->getConnection(); |
115 | 115 | $this->db_table_name = $table_name; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * $TDBMObject_state = "loaded" when the object is cached in memory. |
155 | 155 | * @return string |
156 | 156 | */ |
157 | - public function getTDBMObjectState(){ |
|
157 | + public function getTDBMObjectState() { |
|
158 | 158 | return $this->TDBMObject_state; |
159 | 159 | } |
160 | 160 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * $TDBMObject_state = "loaded" when the object is cached in memory. |
167 | 167 | * @param string $state |
168 | 168 | */ |
169 | - public function setTDBMObjectState($state){ |
|
169 | + public function setTDBMObjectState($state) { |
|
170 | 170 | $this->TDBMObject_state = $state; |
171 | 171 | } |
172 | 172 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | public function loadFromRow($row, &$colsArray) { |
183 | 183 | if ($colsArray === null) { |
184 | 184 | foreach ($row as $key=>$value) { |
185 | - if (strpos($key, 'tdbm_reserved_col_')!==0) { |
|
185 | + if (strpos($key, 'tdbm_reserved_col_') !== 0) { |
|
186 | 186 | $colsArray[$key] = true; |
187 | 187 | } |
188 | 188 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $result = $this->db_connection->query($sql); |
221 | 221 | |
222 | 222 | |
223 | - if ($result->rowCount()==0) |
|
223 | + if ($result->rowCount() == 0) |
|
224 | 224 | { |
225 | 225 | throw new TDBMException("Could not retrieve object from table \"$this->db_table_name\" with ID \"".$this->TDBMObject_id."\"."); |
226 | 226 | } |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | $result->closeCursor(); |
231 | 231 | |
232 | 232 | $this->db_row = array(); |
233 | - foreach ($fullCaseRow[0] as $key=>$value) { |
|
234 | - $this->db_row[$this->db_connection->toStandardCaseColumn($key)]=$value; |
|
233 | + foreach ($fullCaseRow[0] as $key=>$value) { |
|
234 | + $this->db_row[$this->db_connection->toStandardCaseColumn($key)] = $value; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | $this->TDBMObject_state = "loaded"; |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | // Let's try to be accurate in error reporting. The checkColumnExist returns an array of closest matches. |
264 | 264 | $result_array = $column_exist; |
265 | 265 | |
266 | - if (count($result_array)==1) |
|
266 | + if (count($result_array) == 1) |
|
267 | 267 | $str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant this column: '".$result_array[0]."'"; |
268 | 268 | else |
269 | - $str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant one of those columns: '".implode("', '",$result_array)."'"; |
|
269 | + $str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant one of those columns: '".implode("', '", $result_array)."'"; |
|
270 | 270 | |
271 | 271 | |
272 | 272 | throw new TDBMException($str); |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | $pk_array = $this->getPrimaryKey(); |
340 | 340 | |
341 | 341 | foreach ($pk_array as $pk) { |
342 | - if (isset($this->db_row[$pk]) && $this->db_row[$pk]!==null) { |
|
343 | - $pk_set=true; |
|
342 | + if (isset($this->db_row[$pk]) && $this->db_row[$pk] !== null) { |
|
343 | + $pk_set = true; |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | // if there are many columns for the PK, and none is set, we have no way to find the object back! |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | if (!$first) |
364 | 364 | $sql .= ','; |
365 | 365 | $sql .= $this->db_connection->quoteSmart($value); |
366 | - $first=false; |
|
366 | + $first = false; |
|
367 | 367 | } |
368 | 368 | $sql .= ')'; |
369 | 369 | |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | |
392 | 392 | // If there is only one column for the primary key, and if it has not been filled, let's find it. |
393 | 393 | // We assume this is the biggest ID in the database |
394 | - if (count($pk_array)==1 && !$pk_set) { |
|
394 | + if (count($pk_array) == 1 && !$pk_set) { |
|
395 | 395 | // FIXME: for PostgreSQL or MSSQL, the getInsertId call is not thread safe |
396 | 396 | // We should start a transaction before the insert |
397 | - $this->TDBMObject_id = $this->db_connection->getInsertId($this->db_table_name,$pk_array[0]); |
|
397 | + $this->TDBMObject_id = $this->db_connection->getInsertId($this->db_table_name, $pk_array[0]); |
|
398 | 398 | $this->db_row[$pk_array[0]] = $this->TDBMObject_id; |
399 | - } elseif (count($pk_array)==1 && $pk_set) { |
|
399 | + } elseif (count($pk_array) == 1 && $pk_set) { |
|
400 | 400 | $this->TDBMObject_id = $this->db_row[$pk_array[0]]; |
401 | 401 | } |
402 | 402 | |
@@ -423,24 +423,24 @@ discard block |
||
423 | 423 | |
424 | 424 | // Let's add this object to the list of objects in cache. |
425 | 425 | $this->tdbmService->_addToCache($this); |
426 | - } else if ($this->TDBMObject_state == "loaded" && $this->db_modified_state==true) { |
|
426 | + } else if ($this->TDBMObject_state == "loaded" && $this->db_modified_state == true) { |
|
427 | 427 | //$primary_key = $this->getPrimaryKey(); |
428 | 428 | // Let's first get the primary keys |
429 | 429 | $pk_table = $this->getPrimaryKey(); |
430 | 430 | // Now for the object_id |
431 | 431 | $object_id = $this->TDBMObject_id; |
432 | 432 | // If there is only one primary key: |
433 | - if (count($pk_table)==1) { |
|
433 | + if (count($pk_table) == 1) { |
|
434 | 434 | $sql_where = $this->db_connection->escapeDBItem($pk_table[0])."=".$this->db_connection->quoteSmart($this->TDBMObject_id); |
435 | 435 | } else { |
436 | 436 | $ids = unserialize($object_id); |
437 | - $i=0; |
|
437 | + $i = 0; |
|
438 | 438 | $sql_where_array = array(); |
439 | 439 | foreach ($pk_table as $pk) { |
440 | 440 | $sql_where_array[] = $this->db_connection->escapeDBItem($pk)."=".$this->db_connection->quoteSmart($ids[$i]); |
441 | 441 | $i++; |
442 | 442 | } |
443 | - $sql_where = implode(" AND ",$sql_where_array); |
|
443 | + $sql_where = implode(" AND ", $sql_where_array); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | $sql = 'UPDATE '.$this->db_connection->escapeDBItem($this->db_table_name).' SET '; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | if (!$first) |
451 | 451 | $sql .= ','; |
452 | 452 | $sql .= $this->db_connection->escapeDBItem($key)." = ".$this->db_connection->quoteSmart($value); |
453 | - $first=false; |
|
453 | + $first = false; |
|
454 | 454 | } |
455 | 455 | $sql .= ' WHERE '.$sql_where/*$primary_key."='".$this->db_row[$primary_key]."'"*/; |
456 | 456 | try { |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | */ |
513 | 513 | public function __call($func_name, $values) { |
514 | 514 | |
515 | - if (strpos($func_name,"get_") === 0) { |
|
516 | - $table = substr($func_name,4); |
|
515 | + if (strpos($func_name, "get_") === 0) { |
|
516 | + $table = substr($func_name, 4); |
|
517 | 517 | } else { |
518 | 518 | throw new TDBMException("Method ".$func_name." not found"); |
519 | 519 | } |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * Implement the unique JsonSerializable method |
625 | 625 | * @return array |
626 | 626 | */ |
627 | - public function jsonSerialize(){ |
|
627 | + public function jsonSerialize() { |
|
628 | 628 | $this->_dbLoadIfNotLoaded(); |
629 | 629 | return $this->db_row; |
630 | 630 | } |
@@ -653,23 +653,23 @@ discard block |
||
653 | 653 | * |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - private function getPrimaryKeyWhereStatement () { |
|
656 | + private function getPrimaryKeyWhereStatement() { |
|
657 | 657 | // Let's first get the primary keys |
658 | 658 | $pk_table = $this->getPrimaryKey(); |
659 | 659 | // Now for the object_id |
660 | 660 | $object_id = $this->TDBMObject_id; |
661 | 661 | // If there is only one primary key: |
662 | - if (count($pk_table)==1) { |
|
662 | + if (count($pk_table) == 1) { |
|
663 | 663 | $sql_where = $this->db_connection->escapeDBItem($this->db_table_name).'.'.$this->db_connection->escapeDBItem($pk_table[0])."=".$this->db_connection->quoteSmart($this->TDBMObject_id); |
664 | 664 | } else { |
665 | 665 | $ids = unserialize($object_id); |
666 | - $i=0; |
|
666 | + $i = 0; |
|
667 | 667 | $sql_where_array = array(); |
668 | 668 | foreach ($pk_table as $pk) { |
669 | 669 | $sql_where_array[] = $this->db_connection->escapeDBItem($this->db_table_name).'.'.$this->db_connection->escapeDBItem($pk)."=".$this->db_connection->quoteSmart($ids[$i]); |
670 | 670 | $i++; |
671 | 671 | } |
672 | - $sql_where = implode(" AND ",$sql_where_array); |
|
672 | + $sql_where = implode(" AND ", $sql_where_array); |
|
673 | 673 | } |
674 | 674 | return $sql_where; |
675 | 675 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | /** |
678 | 678 | * Override the native php clone function for TDBMObjects |
679 | 679 | */ |
680 | - public function __clone(){ |
|
680 | + public function __clone() { |
|
681 | 681 | $this->_dbLoadIfNotLoaded(); |
682 | 682 | //First lets set the status to new (to enter the save function) |
683 | 683 | $this->TDBMObject_state = "new"; |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | |
87 | 87 | if ($this->fetchStarted === false) { |
88 | 88 | // $keysStandardCased is an optimization to avoid calling toStandardCaseColumn on every cell of every row. |
89 | - foreach ($fullCaseRow as $key=>$value) { |
|
89 | + foreach ($fullCaseRow as $key=>$value) { |
|
90 | 90 | $this->keysStandardCased[$key] = $this->dbConnection->toStandardCaseColumn($key); |
91 | 91 | } |
92 | 92 | $this->fetchStarted = true; |
93 | 93 | } |
94 | - foreach ($fullCaseRow as $key=>$value) { |
|
95 | - $row[$this->keysStandardCased[$key]]=$value; |
|
94 | + foreach ($fullCaseRow as $key=>$value) { |
|
95 | + $row[$this->keysStandardCased[$key]] = $value; |
|
96 | 96 | } |
97 | 97 | |
98 | - if (count($this->primary_keys)==1) |
|
98 | + if (count($this->primary_keys) == 1) |
|
99 | 99 | { |
100 | 100 | if (!isset($this->keysStandardCased[$this->primary_keys[0]])) { |
101 | 101 | throw new TDBMException("Bad SQL request passed to getObjectsFromSQL. The SQL request should return all the rows from the '".$this->table_name."' table. Could not find primary key in this set of rows. SQL request passed: ".$this->sql); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $obj->loadFromRow($row, $this->colsArray); |
132 | 132 | // Check that the object fetched from cache is from the requested class. |
133 | 133 | if ($this->className != null) { |
134 | - if (!is_subclass_of(get_class($obj), $this->className) && get_class($obj) != $this->className) { |
|
134 | + if (!is_subclass_of(get_class($obj), $this->className) && get_class($obj) != $this->className) { |
|
135 | 135 | throw new TDBMException("Error while calling TDBM: An object fetched from database is already present in TDBM cache and they do not share the same class. You requested the object to be of the class ".$this->className." but the object available locally is of the class ".get_class($obj)."."); |
136 | 136 | } |
137 | 137 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // Check that the object fetched from cache is from the requested class. |
140 | 140 | if ($this->className != null) { |
141 | 141 | $this->className = ltrim($this->className, '\\'); |
142 | - if (!is_subclass_of(get_class($obj), $this->className) && get_class($obj) != $this->className) { |
|
142 | + if (!is_subclass_of(get_class($obj), $this->className) && get_class($obj) != $this->className) { |
|
143 | 143 | throw new TDBMException("Error while calling TDBM: An object fetched from database is already present in TDBM cache and they do not share the same class. You requested the object to be of the class ".$this->className." but the object available locally is of the class ".get_class($obj)."."); |
144 | 144 | } |
145 | 145 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $this->current = false; |
186 | 186 | else |
187 | 187 | return true; |
188 | - }else |
|
188 | + } else |
|
189 | 189 | $this->current = false; |
190 | 190 | return false; |
191 | 191 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function valid() |
211 | 211 | { |
212 | - return ($this->current != false) || (($this->cursor == -1) && ($this->count() > 0)); |
|
212 | + return ($this->current != false) || (($this->cursor == -1) && ($this->count()>0)); |
|
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * Fetches first record and rewinds the cursor |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function hasNext() |
228 | 228 | { |
229 | - return ($this->count() > 0) && (($this->cursor + 1) < $this->count()); |
|
229 | + return ($this->count()>0) && (($this->cursor+1)<$this->count()); |
|
230 | 230 | } |
231 | 231 | /** |
232 | 232 | * Return the next record to which this cursor points, and advance the cursor |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | private $tableToBeanMap = []; |
149 | 149 | |
150 | 150 | public function __construct() { |
151 | - register_shutdown_function(array($this,"completeSaveOnExit")); |
|
151 | + register_shutdown_function(array($this, "completeSaveOnExit")); |
|
152 | 152 | if (extension_loaded('weakref')) { |
153 | 153 | $this->objectStorage = new WeakrefObjectStorage(); |
154 | 154 | } else { |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $objects = $this->getObjects($table_name, $filters, null, null, null, $className); |
369 | 369 | if (count($objects) == 0) { |
370 | 370 | return null; |
371 | - } elseif (count($objects) > 1) { |
|
371 | + } elseif (count($objects)>1) { |
|
372 | 372 | throw new DuplicateRowException("Error while querying an object for table '$table_name': ".count($objects)." rows have been returned, but we should have received at most one."); |
373 | 373 | } |
374 | 374 | // Return the first and only object. |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @param string $className Optional: The name of the class to instanciate. This class must extend the TDBMObject class. If none is specified, a TDBMObject instance will be returned. |
446 | 446 | * @return TDBMObject |
447 | 447 | */ |
448 | - public function getNewObject($table_name, $auto_assign_id=true, $className = null) { |
|
448 | + public function getNewObject($table_name, $auto_assign_id = true, $className = null) { |
|
449 | 449 | if ($this->dbConnection == null) { |
450 | 450 | throw new TDBMException("Error while calling TDBMObject::getNewObject(): No connection has been established on the database!"); |
451 | 451 | } |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | $object = new $className($this, $table_name); |
480 | 480 | |
481 | 481 | if ($auto_assign_id && !$this->isPrimaryKeyAutoIncrement($table_name)) { |
482 | - $pk_table = $this->getPrimaryKeyStatic($table_name); |
|
483 | - if (count($pk_table)==1) |
|
482 | + $pk_table = $this->getPrimaryKeyStatic($table_name); |
|
483 | + if (count($pk_table) == 1) |
|
484 | 484 | { |
485 | 485 | $root_table = $this->dbConnection->findRootSequenceTable($table_name); |
486 | 486 | $id = $this->dbConnection->nextId($root_table); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | $sql = "SELECT MAX(".$this->dbConnection->escapeDBItem($pk_table[0]).") AS maxkey FROM ".$root_table; |
491 | 491 | $res = $this->dbConnection->getAll($sql); |
492 | 492 | // NOTE: this will work only if the ID is an integer! |
493 | - $newid = $res[0]['maxkey'] + 1; |
|
493 | + $newid = $res[0]['maxkey']+1; |
|
494 | 494 | if ($newid>$id) { |
495 | 495 | $id = $newid; |
496 | 496 | } |
@@ -520,17 +520,17 @@ discard block |
||
520 | 520 | // Now for the object_id |
521 | 521 | $object_id = $object->TDBMObject_id; |
522 | 522 | // If there is only one primary key: |
523 | - if (count($pk_table)==1) { |
|
523 | + if (count($pk_table) == 1) { |
|
524 | 524 | $sql_where = $this->dbConnection->escapeDBItem($pk_table[0])."=".$this->dbConnection->quoteSmart($object->TDBMObject_id); |
525 | 525 | } else { |
526 | 526 | $ids = unserialize($object_id); |
527 | - $i=0; |
|
527 | + $i = 0; |
|
528 | 528 | $sql_where_array = array(); |
529 | 529 | foreach ($pk_table as $pk) { |
530 | 530 | $sql_where_array[] = $this->dbConnection->escapeDBItem($pk)."=".$this->dbConnection->quoteSmart($ids[$i]); |
531 | 531 | $i++; |
532 | 532 | } |
533 | - $sql_where = implode(" AND ",$sql_where_array); |
|
533 | + $sql_where = implode(" AND ", $sql_where_array); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | * @param string $className Optional: The name of the class to instanciate. This class must extend the TDBMObject class. If none is specified, a TDBMObject instance will be returned. |
614 | 614 | * @return array|Generator|TDBMObjectArray The result set of the query as a TDBMObjectArray (an array of TDBMObjects with special properties) |
615 | 615 | */ |
616 | - public function getObjectsFromSQL($table_name, $sql, $from=null, $limit=null, $className=null) { |
|
616 | + public function getObjectsFromSQL($table_name, $sql, $from = null, $limit = null, $className = null) { |
|
617 | 617 | if ($this->dbConnection == null) { |
618 | 618 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
619 | 619 | } |
@@ -656,10 +656,10 @@ discard block |
||
656 | 656 | $firstLine = false; |
657 | 657 | } |
658 | 658 | foreach ($fullCaseRow as $key=>$value) { |
659 | - $row[$keysStandardCased[$key]]=$value; |
|
659 | + $row[$keysStandardCased[$key]] = $value; |
|
660 | 660 | } |
661 | 661 | $pk_table = $this->primary_keys[$table_name]; |
662 | - if (count($pk_table)==1) |
|
662 | + if (count($pk_table) == 1) |
|
663 | 663 | { |
664 | 664 | if (!isset($keysStandardCased[$pk_table[0]])) { |
665 | 665 | throw new TDBMException("Bad SQL request passed to getObjectsFromSQL. The SQL request should return all the rows from the '$table_name' table. Could not find primary key in this set of rows. SQL request passed: ".$sql); |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | $id = serialize($ids); |
677 | 677 | } |
678 | 678 | |
679 | - $obj = $this->objectStorage->get($table_name,$id); |
|
679 | + $obj = $this->objectStorage->get($table_name, $id); |
|
680 | 680 | if ($obj === null) |
681 | 681 | { |
682 | 682 | if (!is_a($className, "Mouf\\Database\\TDBM\\TDBMObject", true)) { |
@@ -731,10 +731,10 @@ discard block |
||
731 | 731 | $firstLine = false; |
732 | 732 | } |
733 | 733 | foreach ($fullCaseRow as $key=>$value) { |
734 | - $row[$keysStandardCased[$key]]=$value; |
|
734 | + $row[$keysStandardCased[$key]] = $value; |
|
735 | 735 | } |
736 | 736 | $pk_table = $this->primary_keys[$table_name]; |
737 | - if (count($pk_table)==1) |
|
737 | + if (count($pk_table) == 1) |
|
738 | 738 | { |
739 | 739 | if (!isset($keysStandardCased[$pk_table[0]])) { |
740 | 740 | throw new TDBMException("Bad SQL request passed to getObjectsFromSQL. The SQL request should return all the rows from the '$table_name' table. Could not find primary key in this set of rows. SQL request passed: ".$sql); |
@@ -829,14 +829,14 @@ discard block |
||
829 | 829 | // Now, let's commit or rollback if needed. |
830 | 830 | if ($this->dbConnection != null && $this->dbConnection->hasActiveTransaction()) { |
831 | 831 | if ($this->commitOnQuit) { |
832 | - try { |
|
832 | + try { |
|
833 | 833 | $this->dbConnection->commit(); |
834 | 834 | } catch (Exception $e) { |
835 | 835 | echo $e->getMessage()."<br/>"; |
836 | 836 | echo $e->getTraceAsString(); |
837 | 837 | } |
838 | 838 | } else { |
839 | - try { |
|
839 | + try { |
|
840 | 840 | $this->dbConnection->rollback(); |
841 | 841 | } catch (Exception $e) { |
842 | 842 | echo $e->getMessage()."<br/>"; |
@@ -897,21 +897,21 @@ discard block |
||
897 | 897 | * @param string $sql |
898 | 898 | * @return array the result of your query |
899 | 899 | */ |
900 | - public function getTransientObjectsFromSQL($sql,$classname=null) { |
|
900 | + public function getTransientObjectsFromSQL($sql, $classname = null) { |
|
901 | 901 | if ($this->dbConnection == null) { |
902 | 902 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
903 | 903 | } |
904 | - return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS,$classname); |
|
904 | + return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS, $classname); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | |
908 | 908 | private function to_explain_string($path) { |
909 | 909 | $msg = ''; |
910 | 910 | foreach ($path as $constraint) { |
911 | - if ($constraint['type']=='1*') { |
|
911 | + if ($constraint['type'] == '1*') { |
|
912 | 912 | $msg .= 'Table "'.$constraint['table1'].'" points to "'.$constraint['table2'].'" through its foreign key "'.$constraint['col1'].'"\n'; |
913 | 913 | } |
914 | - elseif ($constraint['type']=='*1') { |
|
914 | + elseif ($constraint['type'] == '*1') { |
|
915 | 915 | $msg .= 'Table "'.$constraint['table1'].'" is pointed by "'.$constraint['table2'].'" through its foreign key "'.$constraint['col2'].'"\n'; |
916 | 916 | } |
917 | 917 | } |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | $this->loadCache(); |
931 | 931 | |
932 | 932 | $path = array(); |
933 | - $queue = array(array($table,array())); |
|
933 | + $queue = array(array($table, array())); |
|
934 | 934 | |
935 | 935 | $found = false; |
936 | 936 | $found_depth = 0; |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | { |
966 | 966 | break; |
967 | 967 | } |
968 | - if ($ret==true) |
|
968 | + if ($ret == true) |
|
969 | 969 | { |
970 | 970 | // Ok, we got one, we will continue a bit more until we reach the next level in the tree, |
971 | 971 | // just to see if there is no ambiguity |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | } |
976 | 976 | |
977 | 977 | // At each iteration, let's check the time. |
978 | - if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time > $max_execution_time && $max_execution_time!=0) { |
|
978 | + if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time>$max_execution_time && $max_execution_time != 0) { |
|
979 | 979 | // Call check table names |
980 | 980 | $this->checkTablesExist($tables); |
981 | 981 | |
@@ -986,11 +986,11 @@ discard block |
||
986 | 986 | } |
987 | 987 | } |
988 | 988 | |
989 | - $ambiguity =false; |
|
989 | + $ambiguity = false; |
|
990 | 990 | $msg = ''; |
991 | 991 | foreach ($tables_paths as $table_path) { |
992 | 992 | // If any table has not been found, throw an exception |
993 | - if (!isset($table_path['founddepth']) || $table_path['founddepth']==null) { |
|
993 | + if (!isset($table_path['founddepth']) || $table_path['founddepth'] == null) { |
|
994 | 994 | // First, check if the tables do exist. |
995 | 995 | $this->checkTablesExist(array($table, $table_path['name'])); |
996 | 996 | // Else, throw an error. |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | 'table2' => $depArr['table1'], |
1053 | 1053 | 'col1' => $depArr['col2'], |
1054 | 1054 | 'col2' => $depArr['col1'], |
1055 | - 'type' => (($depArr['type'] == '1*')?'*1':'1*') |
|
1055 | + 'type' => (($depArr['type'] == '1*') ? '*1' : '1*') |
|
1056 | 1056 | ); |
1057 | 1057 | }, $toRevertPath); |
1058 | 1058 | return array_reverse($invertedDependencies); |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | * @param unknown_type $paths |
1071 | 1071 | */ |
1072 | 1072 | private function flatten_paths($paths) { |
1073 | - $flat_path=array(); |
|
1073 | + $flat_path = array(); |
|
1074 | 1074 | foreach ($paths as $path_bigarray) { |
1075 | 1075 | $path = $path_bigarray['paths'][0]; |
1076 | 1076 | |
@@ -1109,9 +1109,9 @@ discard block |
||
1109 | 1109 | $path = $current_vars[1]; |
1110 | 1110 | |
1111 | 1111 | foreach ($target_tables as $id=>$target_table) { |
1112 | - if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth']==null || $target_table['founddepth']==count($path))) { |
|
1112 | + if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth'] == null || $target_table['founddepth'] == count($path))) { |
|
1113 | 1113 | // When a path is found to a table, we mark the table as found with its depth. |
1114 | - $target_tables[$id]['founddepth']=count($path); |
|
1114 | + $target_tables[$id]['founddepth'] = count($path); |
|
1115 | 1115 | |
1116 | 1116 | // Then we add the path to table to the target_tables array |
1117 | 1117 | $target_tables[$id]['paths'][] = $path; |
@@ -1142,12 +1142,12 @@ discard block |
||
1142 | 1142 | $already_done = false; |
1143 | 1143 | foreach ($path as $previous_constraint) |
1144 | 1144 | { |
1145 | - if ($previous_constraint['type']=='1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"]) |
|
1145 | + if ($previous_constraint['type'] == '1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"]) |
|
1146 | 1146 | { |
1147 | 1147 | $already_done = true; |
1148 | 1148 | break; |
1149 | 1149 | } |
1150 | - elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"]) |
|
1150 | + elseif ($previous_constraint['type'] == '*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"]) |
|
1151 | 1151 | { |
1152 | 1152 | $already_done = true; |
1153 | 1153 | break; |
@@ -1175,12 +1175,12 @@ discard block |
||
1175 | 1175 | $already_done = false; |
1176 | 1176 | foreach ($path as $previous_constraint) |
1177 | 1177 | { |
1178 | - if ($previous_constraint['type']=='1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"]) |
|
1178 | + if ($previous_constraint['type'] == '1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"]) |
|
1179 | 1179 | { |
1180 | 1180 | $already_done = true; |
1181 | 1181 | break; |
1182 | 1182 | } |
1183 | - elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"]) |
|
1183 | + elseif ($previous_constraint['type'] == '*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"]) |
|
1184 | 1184 | { |
1185 | 1185 | $already_done = true; |
1186 | 1186 | break; |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1290 | 1290 | * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
1291 | 1291 | */ |
1292 | - public function getObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) { |
|
1292 | + public function getObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) { |
|
1293 | 1293 | if ($this->dbConnection == null) { |
1294 | 1294 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1295 | 1295 | } |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | * @param unknown_type $hint_path |
1306 | 1306 | * @return integer |
1307 | 1307 | */ |
1308 | - public function getCount($table_name, $filter_bag=null, $hint_path=null) { |
|
1308 | + public function getCount($table_name, $filter_bag = null, $hint_path = null) { |
|
1309 | 1309 | if ($this->dbConnection == null) { |
1310 | 1310 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1311 | 1311 | } |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1324 | 1324 | * @return string The SQL that would be executed. |
1325 | 1325 | */ |
1326 | - public function explainSQLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) { |
|
1326 | + public function explainSQLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) { |
|
1327 | 1327 | if ($this->dbConnection == null) { |
1328 | 1328 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1329 | 1329 | } |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1342 | 1342 | * @return string The SQL that would be executed. |
1343 | 1343 | */ |
1344 | - public function explainRequestAsTextGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) { |
|
1344 | + public function explainRequestAsTextGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) { |
|
1345 | 1345 | if ($this->dbConnection == null) { |
1346 | 1346 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1347 | 1347 | } |
@@ -1362,12 +1362,12 @@ discard block |
||
1362 | 1362 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1363 | 1363 | * @return string The SQL that would be executed. |
1364 | 1364 | */ |
1365 | - public function explainRequestAsHTMLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null, $x=10, $y=10) { |
|
1365 | + public function explainRequestAsHTMLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null, $x = 10, $y = 10) { |
|
1366 | 1366 | if ($this->dbConnection == null) { |
1367 | 1367 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1368 | 1368 | } |
1369 | 1369 | $tree = $this->getObjectsByMode('explainTree', $table_name, $filter_bag, $orderby_bag, $from, $limit, $hint_path); |
1370 | - return $this->drawTree($tree,$x,$y); |
|
1370 | + return $this->drawTree($tree, $x, $y); |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | /** |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1385 | 1385 | * @return array|Generator|TDBMObjectArray|int An array or object containing the resulting objects of the query. |
1386 | 1386 | */ |
1387 | - public function getObjectsByMode($mode, $table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) { |
|
1387 | + public function getObjectsByMode($mode, $table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) { |
|
1388 | 1388 | $this->completeSave(); |
1389 | 1389 | $this->loadCache(); |
1390 | 1390 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | } |
1424 | 1424 | } |
1425 | 1425 | |
1426 | - if (count($needed_table_array)==0) |
|
1426 | + if (count($needed_table_array) == 0) |
|
1427 | 1427 | { |
1428 | 1428 | $sql = $this->dbConnection->escapeDBItem($table_name); //Make by Pierre PIV (add escapeDBItem) |
1429 | 1429 | |
@@ -1431,14 +1431,14 @@ discard block |
||
1431 | 1431 | throw new TDBMException("TODO: explainTree not implemented for only one table."); |
1432 | 1432 | } |
1433 | 1433 | else { |
1434 | - if ($hint_path!=null && $mode != 'explainTree') |
|
1434 | + if ($hint_path != null && $mode != 'explainTree') |
|
1435 | 1435 | { |
1436 | 1436 | $path = $hint_path; |
1437 | 1437 | $flat_path = $this->flatten_paths($path); |
1438 | 1438 | } |
1439 | 1439 | else |
1440 | 1440 | { |
1441 | - $full_paths = $this->static_find_paths($table_name,$needed_table_array); |
|
1441 | + $full_paths = $this->static_find_paths($table_name, $needed_table_array); |
|
1442 | 1442 | |
1443 | 1443 | if ($mode == 'explainTree') { |
1444 | 1444 | return $this->getTablePathsTree($full_paths); |
@@ -1481,7 +1481,7 @@ discard block |
||
1481 | 1481 | */ |
1482 | 1482 | $is_ok = true; |
1483 | 1483 | foreach ($path as $step) { |
1484 | - if ($step["type"]=="1*") { |
|
1484 | + if ($step["type"] == "1*") { |
|
1485 | 1485 | $is_ok = false; |
1486 | 1486 | break; |
1487 | 1487 | } |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | $orderby_columns_array = array_merge($orderby_columns_array, $orderby_object->toSqlStatementsArray()); |
1507 | 1507 | } |
1508 | 1508 | |
1509 | - $orderby_statement = ' ORDER BY '.implode(',',$orderby_columns_array); |
|
1509 | + $orderby_statement = ' ORDER BY '.implode(',', $orderby_columns_array); |
|
1510 | 1510 | $count = 0; |
1511 | 1511 | foreach ($orderby_columns_array as $id=>$orderby_statement_phrase) { |
1512 | 1512 | // Let's remove the trailing ASC or DESC and add AS tdbm_reserved_col_Xxx |
@@ -1524,10 +1524,10 @@ discard block |
||
1524 | 1524 | $orderby_columns_array[$id] = $orderby_statement_phrase.' AS tdbm_reserved_col_'.$count; |
1525 | 1525 | $count++; |
1526 | 1526 | } |
1527 | - $orderby_column_statement = ', '.implode(',',$orderby_columns_array); |
|
1527 | + $orderby_column_statement = ', '.implode(',', $orderby_columns_array); |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | - if ($mode=="getCount") { |
|
1530 | + if ($mode == "getCount") { |
|
1531 | 1531 | // Let's get the list of primary keys to perform a DISTINCT request. |
1532 | 1532 | $pk_table = $this->getPrimaryKeyStatic($table_name); |
1533 | 1533 | |
@@ -1561,7 +1561,7 @@ discard block |
||
1561 | 1561 | if ($mode == 'explainSQL') { |
1562 | 1562 | return $sql; |
1563 | 1563 | } |
1564 | - return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1564 | + return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1565 | 1565 | |
1566 | 1566 | } |
1567 | 1567 | |
@@ -1586,17 +1586,17 @@ discard block |
||
1586 | 1586 | // Second, let's take all the objects out of the filter bag, and let's make filters from them |
1587 | 1587 | $filter_bag2 = array(); |
1588 | 1588 | foreach ($filter_bag as $thing) { |
1589 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1589 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1590 | 1590 | $filter_bag2[] = $thing; |
1591 | 1591 | } elseif (is_string($thing)) { |
1592 | 1592 | $filter_bag2[] = new SqlStringFilter($thing); |
1593 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1593 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1594 | 1594 | // Get table_name and column_name |
1595 | 1595 | $filter_table_name = $thing[0]->_getDbTableName(); |
1596 | 1596 | $filter_column_names = $thing[0]->getPrimaryKey(); |
1597 | 1597 | |
1598 | 1598 | // If there is only one primary key, we can use the InFilter |
1599 | - if (count($filter_column_names)==1) { |
|
1599 | + if (count($filter_column_names) == 1) { |
|
1600 | 1600 | $primary_keys_array = array(); |
1601 | 1601 | $filter_column_name = $filter_column_names[0]; |
1602 | 1602 | foreach ($thing as $TDBMObject) { |
@@ -1609,7 +1609,7 @@ discard block |
||
1609 | 1609 | { |
1610 | 1610 | $filter_bag_and = array(); |
1611 | 1611 | foreach ($thing as $TDBMObject) { |
1612 | - $filter_bag_temp_and=array(); |
|
1612 | + $filter_bag_temp_and = array(); |
|
1613 | 1613 | foreach ($filter_column_names as $pk) { |
1614 | 1614 | $filter_bag_temp_and[] = new EqualFilter($TDBMObject->_getDbTableName(), $pk, $TDBMObject->$pk); |
1615 | 1615 | } |
@@ -1619,7 +1619,7 @@ discard block |
||
1619 | 1619 | } |
1620 | 1620 | |
1621 | 1621 | |
1622 | - } elseif (!is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing!==null) { |
|
1622 | + } elseif (!is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing !== null) { |
|
1623 | 1623 | throw new TDBMException("Error in filter bag in getObjectsByFilter. An object has been passed that is neither a filter, nor a TDBMObject, nor a TDBMObjectArray, nor a string, nor null."); |
1624 | 1624 | } |
1625 | 1625 | } |
@@ -1647,9 +1647,9 @@ discard block |
||
1647 | 1647 | // 4-2, let's take all the objects out of the orderby bag, and let's make objects from them |
1648 | 1648 | $orderby_bag2 = array(); |
1649 | 1649 | foreach ($orderby_bag as $thing) { |
1650 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1650 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1651 | 1651 | $orderby_bag2[] = $thing; |
1652 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1652 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1653 | 1653 | $orderby_bag2[] = $thing; |
1654 | 1654 | } elseif (is_string($thing)) { |
1655 | 1655 | $orderby_bag2[] = new OrderBySQLString($thing); |
@@ -1672,10 +1672,10 @@ discard block |
||
1672 | 1672 | $possible_tables = $this->dbConnection->checkTableExist($table); |
1673 | 1673 | if ($possible_tables !== true) |
1674 | 1674 | { |
1675 | - if (count($possible_tables)==1) |
|
1675 | + if (count($possible_tables) == 1) |
|
1676 | 1676 | $str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'"; |
1677 | 1677 | else |
1678 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'"; |
|
1678 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $possible_tables)."'"; |
|
1679 | 1679 | throw new TDBMException($str); |
1680 | 1680 | } |
1681 | 1681 | } |
@@ -1698,16 +1698,16 @@ discard block |
||
1698 | 1698 | $current_node = $tree; |
1699 | 1699 | $found = true; |
1700 | 1700 | foreach ($path as $link) { |
1701 | - if ($found==true) |
|
1701 | + if ($found == true) |
|
1702 | 1702 | { |
1703 | 1703 | if (is_array($current_node->getChildren())) |
1704 | 1704 | { |
1705 | 1705 | foreach ($current_node->getChildren() as $child) |
1706 | 1706 | { |
1707 | - if ($link['table1']==$child->table_name && |
|
1708 | - $link['col1']==$child->keyNode && |
|
1709 | - $link['col2']==$child->keyParent && |
|
1710 | - $link['type']==$child->link_type) { |
|
1707 | + if ($link['table1'] == $child->table_name && |
|
1708 | + $link['col1'] == $child->keyNode && |
|
1709 | + $link['col2'] == $child->keyParent && |
|
1710 | + $link['type'] == $child->link_type) { |
|
1711 | 1711 | $current_node = $child; |
1712 | 1712 | } |
1713 | 1713 | else |
@@ -1722,7 +1722,7 @@ discard block |
||
1722 | 1722 | |
1723 | 1723 | } |
1724 | 1724 | |
1725 | - if ($found==false) |
|
1725 | + if ($found == false) |
|
1726 | 1726 | { |
1727 | 1727 | $current_node = new DisplayNode($link['table1'], $current_node, $link['type'], $link['col2'], $link['col1']); |
1728 | 1728 | } |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | * |
1748 | 1748 | * @return string |
1749 | 1749 | */ |
1750 | - public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) { |
|
1750 | + public function drawTree($tree, $x, $y, &$ret_width = 0, &$ret_height = 0) { |
|
1751 | 1751 | |
1752 | 1752 | // Let's get the background div: |
1753 | 1753 | $treeDepth = $tree->computeDepth(1)-1; |
@@ -1758,7 +1758,7 @@ discard block |
||
1758 | 1758 | |
1759 | 1759 | $str = "<div style='position:absolute; left:".($x+DisplayNode::$left_start-DisplayNode::$border)."px; top:".($y+DisplayNode::$top_start-DisplayNode::$border)."px; width:".$ret_width."px; height:".$ret_height."; background-color:#EEEEEE; color: white; text-align:center;'></div>"; |
1760 | 1760 | |
1761 | - $str .= $tree->draw(0,0, $x, $y); |
|
1761 | + $str .= $tree->draw(0, 0, $x, $y); |
|
1762 | 1762 | |
1763 | 1763 | return $str; |
1764 | 1764 | } |
@@ -1793,10 +1793,10 @@ discard block |
||
1793 | 1793 | if ($tables === true) |
1794 | 1794 | throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table."); |
1795 | 1795 | elseif ($tables !== null) { |
1796 | - if (count($tables)==1) |
|
1796 | + if (count($tables) == 1) |
|
1797 | 1797 | $str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'"; |
1798 | 1798 | else |
1799 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'"; |
|
1799 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $tables)."'"; |
|
1800 | 1800 | throw new TDBMException($str); |
1801 | 1801 | } |
1802 | 1802 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $baseBeanName = $this->getBaseBeanNameFromTableName($tableName); |
93 | 93 | |
94 | 94 | $connection = $this->dbConnection; |
95 | - if ($connection instanceof CachedConnection){ |
|
95 | + if ($connection instanceof CachedConnection) { |
|
96 | 96 | $connection->cacheService->purgeAll(); |
97 | 97 | } |
98 | 98 | |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @dbType '.$normalizedType.' |
185 | 185 | * @dbColumn '.$column->name.' |
186 | - * @return '.($castDatesToDateTime?'\\DateTimeImmutable|null':'timestamp|null').' |
|
186 | + * @return '.($castDatesToDateTime ? '\\DateTimeImmutable|null' : 'timestamp|null').' |
|
187 | 187 | */ |
188 | 188 | public function '.$columnGetterName.'() { |
189 | 189 | $date = $this->__get(\''.$column->name.'\'); |
190 | 190 | if($date === null) { |
191 | 191 | return null; |
192 | 192 | } else { |
193 | - return '.($castDatesToDateTime?'new \\DateTimeImmutable':'strtotime').'($date'.($storeInUtc?'.\' UTC\'':'').'); |
|
193 | + return '.($castDatesToDateTime ? 'new \\DateTimeImmutable' : 'strtotime').'($date'.($storeInUtc ? '.\' UTC\'' : '').'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | * It must be provided as a PHP timestamp. |
200 | 200 | * |
201 | 201 | * @dbColumn '.$column->name.' |
202 | - * @param '.($castDatesToDateTime?'\\DateTimeImmutable|null':'timestamp|null').' $'.$column->name.' |
|
202 | + * @param '.($castDatesToDateTime ? '\\DateTimeImmutable|null' : 'timestamp|null').' $'.$column->name.' |
|
203 | 203 | */ |
204 | - public function '.$columnSetterName.'('.($castDatesToDateTime?'\\DateTimeImmutable ':'').'$'.$column->name.') { |
|
204 | + public function '.$columnSetterName.'('.($castDatesToDateTime ? '\\DateTimeImmutable ' : '').'$'.$column->name.') { |
|
205 | 205 | if($'.$column->name.' === null) { |
206 | 206 | $this->__set(\''.$column->name.'\', null); |
207 | 207 | } else {'; |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | |
313 | 313 | // Now, let's implement the shortcuts to the getter of objects. |
314 | 314 | // Shortcuts are used to save typing. They are available only if a referenced table is referenced only once by our tables. |
315 | - foreach($referencedTablesList as $referrencedTable=>$number) { |
|
315 | + foreach ($referencedTablesList as $referrencedTable=>$number) { |
|
316 | 316 | if ($number == 1) { |
317 | 317 | foreach ($constraints as $array) { |
318 | - if ($array['table2'] ==$referrencedTable) { |
|
318 | + if ($array['table2'] == $referrencedTable) { |
|
319 | 319 | $columnName = $array['col1']; |
320 | 320 | $targetColumnName = $array['col2']; |
321 | 321 | break; |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | |
405 | 405 | }"; |
406 | 406 | $this->ensureDirectoryExist($possibleFileName); |
407 | - file_put_contents($possibleFileName ,$str); |
|
407 | + file_put_contents($possibleFileName, $str); |
|
408 | 408 | @chmod($possibleFileName, 0664); |
409 | 409 | } |
410 | 410 | } |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | foreach ($info as $index => $data) { |
423 | 423 | $comments = $data['column_comment']; |
424 | 424 | $matches = array(); |
425 | - if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0){ |
|
425 | + if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0) { |
|
426 | 426 | $defaultSort = $data['column_name']; |
427 | - if (count($matches == 3)){ |
|
427 | + if (count($matches == 3)) { |
|
428 | 428 | $defaultSortDirection = $matches[2]; |
429 | - }else{ |
|
429 | + } else { |
|
430 | 430 | $defaultSortDirection = 'ASC'; |
431 | 431 | } |
432 | 432 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0]; |
667 | 667 | |
668 | 668 | $this->ensureDirectoryExist($possibleBaseFileName); |
669 | - file_put_contents($possibleBaseFileName ,$str); |
|
669 | + file_put_contents($possibleBaseFileName, $str); |
|
670 | 670 | @chmod($possibleBaseFileName, 0664); |
671 | 671 | |
672 | 672 | $possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className); |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | }"; |
696 | 696 | $this->ensureDirectoryExist($possibleFileName); |
697 | - file_put_contents($possibleFileName ,$str); |
|
697 | + file_put_contents($possibleFileName, $str); |
|
698 | 698 | @chmod($possibleFileName, 0664); |
699 | 699 | } |
700 | 700 | } |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | $possibleFileName = $this->rootPath.$possibleFileNames[0]; |
768 | 768 | |
769 | 769 | $this->ensureDirectoryExist($possibleFileName); |
770 | - file_put_contents($possibleFileName ,$str); |
|
770 | + file_put_contents($possibleFileName, $str); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | /** |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | * @return string |
835 | 835 | */ |
836 | 836 | public static function toCamelCase($str) { |
837 | - $str = strtoupper(substr($str,0,1)).substr($str,1); |
|
837 | + $str = strtoupper(substr($str, 0, 1)).substr($str, 1); |
|
838 | 838 | while (true) { |
839 | 839 | if (strpos($str, "_") === false && strpos($str, " ") === false) |
840 | 840 | break; |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | if ($pos === false) { |
844 | 844 | $pos = strpos($str, " "); |
845 | 845 | } |
846 | - $before = substr($str,0,$pos); |
|
847 | - $after = substr($str,$pos+1); |
|
848 | - $str = $before.strtoupper(substr($after,0,1)).substr($after,1); |
|
846 | + $before = substr($str, 0, $pos); |
|
847 | + $after = substr($str, $pos+1); |
|
848 | + $str = $before.strtoupper(substr($after, 0, 1)).substr($after, 1); |
|
849 | 849 | } |
850 | 850 | return $str; |
851 | 851 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | <div class="control-group"> |
38 | 38 | <label class="control-label">Cast dates as <code>DateTimeImmutable</code>:</label> |
39 | 39 | <div class="controls"> |
40 | - <input type="checkbox" name="castDatesToDateTime" value="1" <?php echo $this->castDatesToDateTime?'checked="checked"':"" ?>></input> |
|
40 | + <input type="checkbox" name="castDatesToDateTime" value="1" <?php echo $this->castDatesToDateTime ? 'checked="checked"' : "" ?>></input> |
|
41 | 41 | <span class="help-block">Select this option if you want dates to be returned as <code>DateTimeImmutable</code>. |
42 | 42 | This is highly recommended. If you do not select this box, getters and setters will return / expect a timestamp |
43 | 43 | (this was the default behaviour up to TDBM 3.3).</span> |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | <div class="control-group"> |
47 | 47 | <label class="control-label">Store dates / timestamps in UTC:</label> |
48 | 48 | <div class="controls"> |
49 | - <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input> |
|
49 | + <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input> |
|
50 | 50 | <span class="help-block">Select this option if you want timestamps to be stored in UTC. |
51 | 51 | If your application supports several time zones, you should select this option to store all dates in |
52 | 52 | the same time zone.</span> |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | <div class="control-group"> |
46 | 46 | <label class="control-label">Keep support for previous DAOs:</label> |
47 | 47 | <div class="controls"> |
48 | - <input type="checkbox" name="keepSupport" <?php echo $this->keepSupport?'checked="checked"':"" ?>></input> |
|
48 | + <input type="checkbox" name="keepSupport" <?php echo $this->keepSupport ? 'checked="checked"' : "" ?>></input> |
|
49 | 49 | <span class="help-block">DAOs generated before TDBM 2.3 had a different method signature. This will ensure this signature |
50 | 50 | is respected. Use this only if you are migrating legacy code.</span> |
51 | 51 | </div> |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | <div class="control-group"> |
54 | 54 | <label class="control-label">Cast dates as <code>DateTimeImmutable</code>:</label> |
55 | 55 | <div class="controls"> |
56 | - <input type="checkbox" name="castDatesToDateTime" value="1" <?php echo $this->castDatesToDateTime?'checked="checked"':"" ?>></input> |
|
56 | + <input type="checkbox" name="castDatesToDateTime" value="1" <?php echo $this->castDatesToDateTime ? 'checked="checked"' : "" ?>></input> |
|
57 | 57 | <span class="help-block">Select this option if you want dates to be returned as <code>DateTimeImmutable</code>. |
58 | 58 | This is highly recommended. If you do not select this box, getters and setters will return / expect a timestamp |
59 | 59 | (this was the default behaviour up to TDBM 3.3).</span> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | <div class="control-group"> |
63 | 63 | <label class="control-label">Store dates / timestamps in UTC:</label> |
64 | 64 | <div class="controls"> |
65 | - <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input> |
|
65 | + <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input> |
|
66 | 66 | <span class="help-block">Select this option if you want timestamps to be stored in UTC. |
67 | 67 | If your application supports several time zones, you should select this option to store all dates in |
68 | 68 | the same time zone.</span> |