Completed
Pull Request — 3.3 (#154)
by Thibault
20:28
created
src/Mouf/Database/TDBM/Filters/OrderBySQLString.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,14 +133,14 @@
 block discarded – undo
133 133
 		$work_table = explode("'", $work_str);
134 134
 
135 135
 		if (count($work_table) == 0)
136
-		    return '';
136
+			return '';
137 137
 
138 138
 		// if we start with a ', let's remove the first text
139 139
 		if (strstr($work_str,"'") === 0)
140
-		    array_shift($work_table);
140
+			array_shift($work_table);
141 141
 			
142 142
 		if (count($work_table) == 0)
143
-		    return '';
143
+			return '';
144 144
 
145 145
 		// Now, let's take only the stuff outside the quotes.
146 146
 		$work_str2 = '';
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/AmbiguityException.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	private function getAllPossiblePaths() {
48
-        return AmbiguityException::getAllPossiblePathsRec($this->paths);
48
+		return AmbiguityException::getAllPossiblePathsRec($this->paths);
49 49
 	}
50 50
 
51 51
 	private static function getAllPossiblePathsRec($sub_table_paths)
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObjectArray.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,9 +65,9 @@
 block discarded – undo
65 65
 	 * @param string $func_name
66 66
 	 * @param $values
67 67
 	 * @return array|void
68
-     * @throws TDBMException
68
+	 * @throws TDBMException
69 69
 	 */
70
-    public function __call($func_name, $values) {
70
+	public function __call($func_name, $values) {
71 71
 
72 72
 		if (strpos($func_name,"getarray_") === 0) {
73 73
 			$column = substr($func_name, 9);
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/BetweenFilter.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * 
99 99
 	 * @param string $tableName
100 100
 	 * @param string $columnName
101
-     * @param string $value1
102
-     * @param string $value2
101
+	 * @param string $value1
102
+	 * @param string $value2
103 103
 	 */
104 104
 	public function __construct($tableName=null, $columnName=null, $value1=null, $value2=null) {
105 105
 		$this->tableName = $tableName;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @param ConnectionInterface $dbConnection
115 115
 	 * @return string
116
-     * @throws \Mouf\Database\TDBM\TDBMException
116
+	 * @throws \Mouf\Database\TDBM\TDBMException
117 117
 	 */
118
-    public function toSql(ConnectionInterface $dbConnection) {
118
+	public function toSql(ConnectionInterface $dbConnection) {
119 119
 		if ($this->enableCondition != null && !$this->enableCondition->isOk()) {
120 120
 			return "";
121 121
 		}
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/OrFilter.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @param ConnectionInterface $dbConnection
70 70
 	 * @return string
71
-     * @throws TDBMException
71
+	 * @throws TDBMException
72 72
 	 */
73
-    public function toSql(ConnectionInterface $dbConnection) {
73
+	public function toSql(ConnectionInterface $dbConnection) {
74 74
 		if ($this->enableCondition != null && !$this->enableCondition->isOk()) {
75 75
 			return "";
76 76
 		}
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return array<string>
104 104
 	 */
105
-    public function getUsedTables() {
106
-        if ($this->enableCondition != null && !$this->enableCondition->isOk()) {
107
-            return array();
108
-        }
109
-
110
-        $tables = array();
111
-        foreach ($this->filters as $filter) {
112
-
113
-            if (!$filter instanceof FilterInterface) {
114
-                throw new TDBMException("Error in OrFilter: One of the parameters is not a filter.");
115
-            }
116
-
117
-            $tables = array_merge($tables,$filter->getUsedTables());
118
-        }
119
-        // Remove tables in double.
120
-        $tables = array_flip(array_flip($tables));
121
-        return $tables;
122
-    }
105
+	public function getUsedTables() {
106
+		if ($this->enableCondition != null && !$this->enableCondition->isOk()) {
107
+			return array();
108
+		}
109
+
110
+		$tables = array();
111
+		foreach ($this->filters as $filter) {
112
+
113
+			if (!$filter instanceof FilterInterface) {
114
+				throw new TDBMException("Error in OrFilter: One of the parameters is not a filter.");
115
+			}
116
+
117
+			$tables = array_merge($tables,$filter->getUsedTables());
118
+		}
119
+		// Remove tables in double.
120
+		$tables = array_flip(array_flip($tables));
121
+		return $tables;
122
+	}
123 123
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObject.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -170,26 +170,26 @@  discard block
 block discarded – undo
170 170
 		$this->TDBMObject_state = $state;	
171 171
 	}
172 172
 
173
-    /**
174
-     * Internal TDBM method, you should not use this.
175
-     * Loads the db_row property of the object from the $row array.
176
-     * Any row having a key starting with 'tdbm_reserved_col_' is ignored.
177
-     *
178
-     * @param array $row
179
-     * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should
180
-     *                              contain as keys the list of interesting columns. If null, this list will be initialized.
181
-     */
173
+	/**
174
+	 * Internal TDBM method, you should not use this.
175
+	 * Loads the db_row property of the object from the $row array.
176
+	 * Any row having a key starting with 'tdbm_reserved_col_' is ignored.
177
+	 *
178
+	 * @param array $row
179
+	 * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should
180
+	 *                              contain as keys the list of interesting columns. If null, this list will be initialized.
181
+	 */
182 182
 	public function loadFromRow($row, &$colsArray) {
183
-        if ($colsArray === null) {
184
-            foreach ($row as $key=>$value) {
185
-                if (strpos($key, 'tdbm_reserved_col_')!==0) {
186
-                    $colsArray[$key] = true;
187
-                }
188
-            }
189
-        }
190
-
191
-        $this->db_row = array_intersect_key($row, $colsArray);
192
-        $this->TDBMObject_state = "loaded";
183
+		if ($colsArray === null) {
184
+			foreach ($row as $key=>$value) {
185
+				if (strpos($key, 'tdbm_reserved_col_')!==0) {
186
+					$colsArray[$key] = true;
187
+				}
188
+			}
189
+		}
190
+
191
+		$this->db_row = array_intersect_key($row, $colsArray);
192
+		$this->TDBMObject_state = "loaded";
193 193
 	}
194 194
 
195 195
 	/**
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 	 *
508 508
 	 * @param string $func_name
509 509
 	 * @param $values
510
-     * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query.
511
-     * @throws TDBMException
510
+	 * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query.
511
+	 * @throws TDBMException
512 512
 	 */
513
-    public function __call($func_name, $values) {
513
+	public function __call($func_name, $values) {
514 514
 
515 515
 		if (strpos($func_name,"get_") === 0) {
516 516
 			$table = substr($func_name,4);
@@ -545,48 +545,48 @@  discard block
 block discarded – undo
545 545
 	}
546 546
 	
547 547
 		/**
548
-	 * Implements array behaviour for our object.
549
-	 * 
550
-	 * @param string $offset
551
-	 * @param string $value
552
-	 */
548
+		 * Implements array behaviour for our object.
549
+		 * 
550
+		 * @param string $offset
551
+		 * @param string $value
552
+		 */
553 553
 	public function offsetSet($offset, $value) {
554 554
 		$this->__set($offset, $value);
555
-    }
555
+	}
556 556
 	/**
557 557
 	 * Implements array behaviour for our object.
558 558
 	 * 
559 559
 	 * @param string $offset
560
-     * @return bool
560
+	 * @return bool
561 561
 	 */
562
-    public function offsetExists($offset) {
563
-    	$this->_dbLoadIfNotLoaded();
564
-        return isset($this->db_row[$offset]);
565
-    }
562
+	public function offsetExists($offset) {
563
+		$this->_dbLoadIfNotLoaded();
564
+		return isset($this->db_row[$offset]);
565
+	}
566 566
 	/**
567 567
 	 * Implements array behaviour for our object.
568 568
 	 * 
569 569
 	 * @param string $offset
570 570
 	 */
571
-    public function offsetUnset($offset) {
571
+	public function offsetUnset($offset) {
572 572
 		$this->__set($offset, null);
573
-    }
573
+	}
574 574
 	/**
575 575
 	 * Implements array behaviour for our object.
576 576
 	 * 
577 577
 	 * @param string $offset
578
-     * @return mixed|null
578
+	 * @return mixed|null
579 579
 	 */
580
-    public function offsetGet($offset) {
581
-        return $this->__get($offset);
582
-    }
580
+	public function offsetGet($offset) {
581
+		return $this->__get($offset);
582
+	}
583 583
 	
584 584
 	private $_validIterator = false;
585 585
 	/**
586 586
 	 * Implements iterator behaviour for our object (so we can each column).
587 587
 	 */
588 588
 	public function rewind() {
589
-    	$this->_dbLoadIfNotLoaded();
589
+		$this->_dbLoadIfNotLoaded();
590 590
 		if (count($this->db_row)>0) {
591 591
 			$this->_validIterator = true;
592 592
 		} else {
@@ -674,21 +674,21 @@  discard block
 block discarded – undo
674 674
 		return $sql_where;
675 675
 	}
676 676
 
677
-    /**
678
-     * Override the native php clone function for TDBMObjects
679
-     */
680
-    public function __clone(){
681
-        $this->_dbLoadIfNotLoaded();
682
-        //First lets set the status to new (to enter the save function)
683
-        $this->TDBMObject_state = "new";
684
-
685
-        // Add the current TDBMObject to the save object list
686
-        $this->tdbmService->_addToToSaveObjectList($this);
687
-
688
-        //Now unset the PK from the row
689
-        $pk_array = $this->getPrimaryKey();
690
-        foreach ($pk_array as $pk) {
691
-            $this->db_row[$pk] = null;
692
-        }
693
-    }
677
+	/**
678
+	 * Override the native php clone function for TDBMObjects
679
+	 */
680
+	public function __clone(){
681
+		$this->_dbLoadIfNotLoaded();
682
+		//First lets set the status to new (to enter the save function)
683
+		$this->TDBMObject_state = "new";
684
+
685
+		// Add the current TDBMObject to the save object list
686
+		$this->tdbmService->_addToToSaveObjectList($this);
687
+
688
+		//Now unset the PK from the row
689
+		$pk_array = $this->getPrimaryKey();
690
+		foreach ($pk_array as $pk) {
691
+			$this->db_row[$pk] = null;
692
+		}
693
+	}
694 694
 }
695 695
\ No newline at end of file
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObjectArrayCursorIterator.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	protected $current = false;
57 57
 
58
-    private $colsArray = null;
58
+	private $colsArray = null;
59 59
 	
60 60
 	public function __construct(\PDOStatement $pdoStatement, ConnectionInterface $dbConnection, $primary_keys, $table_name, $objectStorage, $className, TDBMService $tdbmService, $sql)
61 61
 	{
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 	 * Casts a document to a new instance specified in the $recordClass
74 74
 	 * @param array $fullCaseRow
75 75
 	 * @return Record_Abstract|false
76
-     * @throws TDBMException
76
+	 * @throws TDBMException
77 77
 	 */
78
-    protected function cast($fullCaseRow)
78
+	protected function cast($fullCaseRow)
79 79
 	{
80 80
 		if (!is_array($fullCaseRow)) {
81 81
 			return false;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/TDBMDaoGenerator.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $support, $storeInUtc) {
67 67
 		// TODO: migrate $this->daoNamespace to $daonamespace that is passed in parameter!
68 68
 
69
-        $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
69
+		$classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
70 70
 
71 71
 		$this->daoNamespace = $daonamespace;
72 72
 		$this->beanNamespace = $beannamespace;
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
 		$beanName = $this->getBeanNameFromTableName($tableName);
99 99
 		$baseBeanName = $this->getBaseBeanNameFromTableName($tableName);
100 100
 
101
-        $connection = $this->dbConnection;
102
-        if ($connection instanceof CachedConnection){
103
-            $connection->cacheService->purgeAll();
104
-        }
101
+		$connection = $this->dbConnection;
102
+		if ($connection instanceof CachedConnection){
103
+			$connection->cacheService->purgeAll();
104
+		}
105 105
 		
106 106
 		$this->generateBean($beanName, $baseBeanName, $tableName, $beannamespace, $classNameMapper);
107 107
 		$this->generateDao($daoName, $daoName."Base", $beanName, $tableName, $classNameMapper);
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 		return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."BaseBean";
138 138
 	}
139 139
 
140
-    /**
141
-     * Writes the PHP bean file with all getters and setters from the table passed in parameter.
142
-     *
143
-     * @param string $className The name of the class
144
-     * @param string $baseClassName The name of the base class which will be extended (name only, no directory)
145
-     * @param string $tableName The name of the table
146
-     * @param string $beannamespace The namespace of the bean
147
-     * @param ClassNameMapper $classNameMapper
148
-     * @throws TDBMException
149
-     */
140
+	/**
141
+	 * Writes the PHP bean file with all getters and setters from the table passed in parameter.
142
+	 *
143
+	 * @param string $className The name of the class
144
+	 * @param string $baseClassName The name of the base class which will be extended (name only, no directory)
145
+	 * @param string $tableName The name of the table
146
+	 * @param string $beannamespace The namespace of the bean
147
+	 * @param ClassNameMapper $classNameMapper
148
+	 * @throws TDBMException
149
+	 */
150 150
 	public function generateBean($className, $baseClassName, $tableName, $beannamespace, ClassNameMapper $classNameMapper) {
151 151
 		$table = $this->dbConnection->getTableFromDbModel($tableName);
152 152
 
@@ -361,25 +361,25 @@  discard block
 block discarded – undo
361 361
 		$str .= "}
362 362
 ?>";
363 363
 
364
-        $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName);
365
-        if (!$possibleBaseFileNames) {
366
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.');
367
-        }
368
-        $possibleBaseFileName = __DIR__.'/../../../../../../../../'.$possibleBaseFileNames[0];
364
+		$possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName);
365
+		if (!$possibleBaseFileNames) {
366
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.');
367
+		}
368
+		$possibleBaseFileName = __DIR__.'/../../../../../../../../'.$possibleBaseFileNames[0];
369 369
 
370
-        $this->ensureDirectoryExist($possibleBaseFileName);
370
+		$this->ensureDirectoryExist($possibleBaseFileName);
371 371
 		file_put_contents($possibleBaseFileName, $str);
372 372
 		@chmod($possibleBaseFileName, 0664);
373 373
 
374 374
 
375 375
 
376
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className);
377
-        if (!$possibleFileNames) {
378
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.');
379
-        }
380
-        $possibleFileName = __DIR__.'/../../../../../../../../'.$possibleFileNames[0];
376
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className);
377
+		if (!$possibleFileNames) {
378
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.');
379
+		}
380
+		$possibleFileName = __DIR__.'/../../../../../../../../'.$possibleFileNames[0];
381 381
 
382
-        if (!file_exists($possibleFileName)) {
382
+		if (!file_exists($possibleFileName)) {
383 383
 			$str = "<?php
384 384
 /*
385 385
  * This file has been automatically generated by TDBM.
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 {
398 398
 
399 399
 }";
400
-            $this->ensureDirectoryExist($possibleFileName);
400
+			$this->ensureDirectoryExist($possibleFileName);
401 401
 			file_put_contents($possibleFileName ,$str);
402 402
 			@chmod($possibleFileName, 0664);
403 403
 		}
@@ -653,21 +653,21 @@  discard block
 block discarded – undo
653 653
 }
654 654
 ?>";
655 655
 
656
-        $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$baseClassName);
657
-        if (!$possibleBaseFileNames) {
658
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.');
659
-        }
660
-        $possibleBaseFileName = __DIR__.'/../../../../../../../../'.$possibleBaseFileNames[0];
656
+		$possibleBaseFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$baseClassName);
657
+		if (!$possibleBaseFileNames) {
658
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.');
659
+		}
660
+		$possibleBaseFileName = __DIR__.'/../../../../../../../../'.$possibleBaseFileNames[0];
661 661
 
662
-        $this->ensureDirectoryExist($possibleBaseFileName);
662
+		$this->ensureDirectoryExist($possibleBaseFileName);
663 663
 		file_put_contents($possibleBaseFileName ,$str);
664 664
 		@chmod($possibleBaseFileName, 0664);
665 665
 
666
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className);
667
-        if (!$possibleFileNames) {
668
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.');
669
-        }
670
-        $possibleFileName = __DIR__.'/../../../../../../../../'.$possibleFileNames[0];
666
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className);
667
+		if (!$possibleFileNames) {
668
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.');
669
+		}
670
+		$possibleFileName = __DIR__.'/../../../../../../../../'.$possibleFileNames[0];
671 671
 		
672 672
 		// Now, let's generate the "editable" class
673 673
 		if (!file_exists($possibleFileName)) {
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 {
688 688
 
689 689
 }";
690
-            $this->ensureDirectoryExist($possibleFileName);
690
+			$this->ensureDirectoryExist($possibleFileName);
691 691
 			file_put_contents($possibleFileName ,$str);
692 692
 			@chmod($possibleFileName, 0664);
693 693
 		}
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
 }
755 755
 ?>';
756 756
 
757
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName);
758
-        if (!$possibleFileNames) {
759
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.');
760
-        }
761
-        $possibleFileName = __DIR__.'/../../../../../../../../'.$possibleFileNames[0];
757
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName);
758
+		if (!$possibleFileNames) {
759
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.');
760
+		}
761
+		$possibleFileName = __DIR__.'/../../../../../../../../'.$possibleFileNames[0];
762 762
 
763
-        $this->ensureDirectoryExist($possibleFileName);
763
+		$this->ensureDirectoryExist($possibleFileName);
764 764
 		file_put_contents($possibleFileName ,$str);
765 765
 	}
766 766
 	
@@ -876,20 +876,20 @@  discard block
 block discarded – undo
876 876
 		return strtolower(substr($str, 0, 1)).substr($str, 1);
877 877
 	}
878 878
 
879
-    /**
880
-     * Ensures the file passed in parameter can be written in its directory.
881
-     * @param string $fileName
882
-     */
883
-    private function ensureDirectoryExist($fileName) {
884
-        $dirName = dirname($fileName);
885
-        if (!file_exists($dirName)) {
886
-            $old = umask(0);
887
-            $result = mkdir($dirName, 0775, true);
888
-            umask($old);
889
-            if ($result == false) {
890
-                echo "Unable to create directory: ".$dirName.".";
891
-                exit;
892
-            }
893
-        }
894
-    }
879
+	/**
880
+	 * Ensures the file passed in parameter can be written in its directory.
881
+	 * @param string $fileName
882
+	 */
883
+	private function ensureDirectoryExist($fileName) {
884
+		$dirName = dirname($fileName);
885
+		if (!file_exists($dirName)) {
886
+			$old = umask(0);
887
+			$result = mkdir($dirName, 0775, true);
888
+			umask($old);
889
+			if ($result == false) {
890
+				echo "Unable to create directory: ".$dirName.".";
891
+				exit;
892
+			}
893
+		}
894
+	}
895 895
 }
896 896
\ No newline at end of file
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMService.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -531,45 +531,45 @@  discard block
 block discarded – undo
531 531
 		}
532 532
 	}
533 533
 
534
-    /**
535
-     * This function removes the given object from the database. It will also remove all objects relied to the one given
536
-     * by parameter before all.
537
-     *
538
-     * Notice: if the object has a multiple primary key, the function will not work.
539
-     *
540
-     * @param TDBMObject $objToDelete
541
-     */
542
-    public function deleteCascade(TDBMObject $objToDelete) {
543
-        $this->deleteAllConstraintWithThisObject($objToDelete);
544
-        $this->deleteObject($objToDelete);
545
-    }
546
-
547
-    /**
548
-     * This function is used only in TDBMService (private function)
549
-     * It will call deleteCascade function foreach object relied with a foreign key to the object given by parameter
550
-     *
551
-     * @param TDBMObject $obj
552
-     * @return TDBMObjectArray
553
-     */
554
-    private function deleteAllConstraintWithThisObject(TDBMObject $obj) {
555
-        $tableFrom = $this->dbConnection->escapeDBItem($obj->_getDbTableName());
556
-        $constraints = $this->dbConnection->getConstraintsFromTable($tableFrom);
557
-        foreach ($constraints as $constraint) {
558
-            $tableTo = $this->dbConnection->escapeDBItem($constraint["table1"]);
559
-            $colFrom = $this->dbConnection->escapeDBItem($constraint["col2"]);
560
-            $colTo = $this->dbConnection->escapeDBItem($constraint["col1"]);
561
-            $idVarName = $this->dbConnection->escapeDBItem($obj->getPrimaryKey()[0]);
562
-            $idValue = $this->dbConnection->quoteSmart($obj->TDBMObject_id);
563
-            $sql = "SELECT DISTINCT ".$tableTo.".*"
564
-                    ." FROM ".$tableFrom
565
-                    ." LEFT JOIN ".$tableTo." ON ".$tableFrom.".".$colFrom." = ".$tableTo.".".$colTo
566
-                    ." WHERE ".$tableFrom.".".$idVarName."=".$idValue;
567
-            $result = $this->getObjectsFromSQL($constraint["table1"], $sql);
568
-            foreach ($result as $tdbmObj) {
569
-                $this->deleteCascade($tdbmObj);
570
-            }
571
-        }
572
-    }
534
+	/**
535
+	 * This function removes the given object from the database. It will also remove all objects relied to the one given
536
+	 * by parameter before all.
537
+	 *
538
+	 * Notice: if the object has a multiple primary key, the function will not work.
539
+	 *
540
+	 * @param TDBMObject $objToDelete
541
+	 */
542
+	public function deleteCascade(TDBMObject $objToDelete) {
543
+		$this->deleteAllConstraintWithThisObject($objToDelete);
544
+		$this->deleteObject($objToDelete);
545
+	}
546
+
547
+	/**
548
+	 * This function is used only in TDBMService (private function)
549
+	 * It will call deleteCascade function foreach object relied with a foreign key to the object given by parameter
550
+	 *
551
+	 * @param TDBMObject $obj
552
+	 * @return TDBMObjectArray
553
+	 */
554
+	private function deleteAllConstraintWithThisObject(TDBMObject $obj) {
555
+		$tableFrom = $this->dbConnection->escapeDBItem($obj->_getDbTableName());
556
+		$constraints = $this->dbConnection->getConstraintsFromTable($tableFrom);
557
+		foreach ($constraints as $constraint) {
558
+			$tableTo = $this->dbConnection->escapeDBItem($constraint["table1"]);
559
+			$colFrom = $this->dbConnection->escapeDBItem($constraint["col2"]);
560
+			$colTo = $this->dbConnection->escapeDBItem($constraint["col1"]);
561
+			$idVarName = $this->dbConnection->escapeDBItem($obj->getPrimaryKey()[0]);
562
+			$idValue = $this->dbConnection->quoteSmart($obj->TDBMObject_id);
563
+			$sql = "SELECT DISTINCT ".$tableTo.".*"
564
+					." FROM ".$tableFrom
565
+					." LEFT JOIN ".$tableTo." ON ".$tableFrom.".".$colFrom." = ".$tableTo.".".$colTo
566
+					." WHERE ".$tableFrom.".".$idVarName."=".$idValue;
567
+			$result = $this->getObjectsFromSQL($constraint["table1"], $sql);
568
+			foreach ($result as $tdbmObj) {
569
+				$this->deleteCascade($tdbmObj);
570
+			}
571
+		}
572
+	}
573 573
 
574 574
 	/**
575 575
 	 * The getObjectsFromSQL is used to retrieve objects from the database using a full SQL query.
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 			}
619 619
 			$keysStandardCased = array();
620 620
 			$firstLine = true;
621
-            $colsArray = null;
621
+			$colsArray = null;
622 622
 			while ($fullCaseRow = $result->fetch(\PDO::FETCH_ASSOC))
623 623
 			{
624 624
 				$row = array();
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 					$id = serialize($ids);
651 651
 				}
652 652
 
653
-                $obj = $this->objectStorage->get($table_name,$id);
653
+				$obj = $this->objectStorage->get($table_name,$id);
654 654
 				if ($obj === null)
655 655
 				{
656 656
 					if ($className == null) {
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
 					} else {
664 664
 						throw new TDBMException("Error while casting TDBMObject to class, the parameter passed is not a string. Value passed: ".$className);
665 665
 					}
666
-                    $obj->loadFromRow($row, $colsArray);
667
-                    $this->objectStorage->set($table_name, $id, $obj);
666
+					$obj->loadFromRow($row, $colsArray);
667
+					$this->objectStorage->set($table_name, $id, $obj);
668 668
 				} elseif ($obj->_getStatus() == "not loaded") {
669
-                    $obj->loadFromRow($row, $colsArray);
669
+					$obj->loadFromRow($row, $colsArray);
670 670
 					// Check that the object fetched from cache is from the requested class.
671 671
 					if ($className != null) {
672 672
 						if (!is_subclass_of(get_class($obj), $className) && get_class($obj) != $className) {
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	private function getObjectsFromSQLGenerator($result, $table_name, $className, $sql) {
704 704
 		$keysStandardCased = array();
705 705
 		$firstLine = true;
706
-        $colsArray = null;
706
+		$colsArray = null;
707 707
 		while ($fullCaseRow = $result->fetch(\PDO::FETCH_ASSOC))
708 708
 		{
709 709
 			$row = array();
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 				}
735 735
 				$id = serialize($ids);
736 736
 			}
737
-            $obj = $this->objectStorage->get($table_name, $id);
737
+			$obj = $this->objectStorage->get($table_name, $id);
738 738
 			if ($obj === null)
739 739
 			{
740 740
 				if ($className == null) {
@@ -747,10 +747,10 @@  discard block
 block discarded – undo
747 747
 				} else {
748 748
 					throw new TDBMException("Error while casting TDBMObject to class, the parameter passed is not a string. Value passed: ".$className);
749 749
 				}
750
-                $obj->loadFromRow($row, $colsArray);
751
-                $this->objectStorage->set($table_name, $id, $obj);
750
+				$obj->loadFromRow($row, $colsArray);
751
+				$this->objectStorage->set($table_name, $id, $obj);
752 752
 			} elseif ($obj->_getStatus() == "not loaded") {
753
-                $obj->loadFromRow($row, $colsArray);
753
+				$obj->loadFromRow($row, $colsArray);
754 754
 				// Check that the object fetched from cache is from the requested class.
755 755
 				if ($className != null) {
756 756
 					if (!is_subclass_of(get_class($obj), $className) && get_class($obj) != $className) {
@@ -1469,13 +1469,13 @@  discard block
 block discarded – undo
1469 1469
 			*/
1470 1470
 			$is_ok = true;
1471 1471
 			if($path){
1472
-                foreach ($path as $step) {
1473
-                    if ($step["type"]=="1*") {
1474
-                        $is_ok = false;
1475
-                        break;
1476
-                    }
1477
-                }
1478
-            }
1472
+				foreach ($path as $step) {
1473
+					if ($step["type"]=="1*") {
1474
+						$is_ok = false;
1475
+						break;
1476
+					}
1477
+				}
1478
+			}
1479 1479
 
1480 1480
 			if (!$is_ok) {
1481 1481
 				throw new TDBMException("Error in querying database from getObjectsByFilter. You tried to order your data according to a column of the '$target_table_table' table. However, the '$target_table_table' table has a many to 1 relationship with the '$table_name' table. This means that one '$table_name' object can contain many '$target_table_table' objects. Therefore, trying to order '$table_name' objects using '$target_table_table' objects is meaningless and cannot be performed.");
@@ -1655,9 +1655,9 @@  discard block
 block discarded – undo
1655 1655
 	 * Throws a TDBMException if one of those table does not exist.
1656 1656
 	 *
1657 1657
 	 * @param array $tables
1658
-     * @throws TDBMException
1658
+	 * @throws TDBMException
1659 1659
 	 */
1660
-    private function checkTablesExist($tables) {
1660
+	private function checkTablesExist($tables) {
1661 1661
 		foreach ($tables as $table) {
1662 1662
 			$possible_tables = $this->dbConnection->checkTableExist($table);
1663 1663
 			if ($possible_tables !== true)
@@ -1730,12 +1730,12 @@  discard block
 block discarded – undo
1730 1730
 	 * This function returns the HTML to draw a tree of DisplayNode.
1731 1731
 	 *
1732 1732
 	 * @param DisplayNode $tree
1733
-     * @param int $x
1734
-     * @param int $y
1735
-     * @param int $ret_width
1736
-     * @param int $ret_height
1737
-     *
1738
-     * @return string
1733
+	 * @param int $x
1734
+	 * @param int $y
1735
+	 * @param int $ret_width
1736
+	 * @param int $ret_height
1737
+	 *
1738
+	 * @return string
1739 1739
 	 */
1740 1740
 	public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) {
1741 1741
 
Please login to merge, or discard this patch.