Completed
Push — scrutinizer ( 5826f3...ba0b09 )
by Fabio
11:34
created
framework/Data/Common/Mssql/TMssqlMetaData.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -123,6 +123,7 @@
 block discarded – undo
123 123
 	/**
124 124
 	 * @param TMssqlTableInfo table information.
125 125
 	 * @param array column information.
126
+	 * @param TMssqlTableInfo $tableInfo
126 127
 	 */
127 128
 	protected function processColumn($tableInfo, $col)
128 129
 	{
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -259,15 +259,15 @@
 block discarded – undo
259 259
 		return false;
260 260
 	}
261 261
 
262
-        /**
263
-	 * Returns all table names in the database.
264
-	 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
265
-	 * If not empty, the returned table names will be prefixed with the schema name.
266
-	 * @return array all table names in the database.
267
-	 */
262
+		/**
263
+		 * Returns all table names in the database.
264
+		 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
265
+		 * If not empty, the returned table names will be prefixed with the schema name.
266
+		 * @return array all table names in the database.
267
+		 */
268 268
 	public function findTableNames($schema='dbo')
269 269
 	{
270
-                $condition="TABLE_TYPE='BASE TABLE'";
270
+				$condition="TABLE_TYPE='BASE TABLE'";
271 271
 		$sql=<<<EOD
272 272
 SELECT TABLE_NAME, TABLE_SCHEMA FROM [INFORMATION_SCHEMA].[TABLES]
273 273
 WHERE TABLE_SCHEMA=:schema AND $condition
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	protected function createTableInfo($table)
71 71
 	{
72
-		list($catalogName,$schemaName,$tableName) = $this->getCatalogSchemaTableName($table);
72
+		list($catalogName, $schemaName, $tableName)=$this->getCatalogSchemaTableName($table);
73 73
 		$this->getDbConnection()->setActive(true);
74
-		$sql = <<<EOD
74
+		$sql=<<<EOD
75 75
 				SELECT t.*,
76 76
 												c.*,
77 77
 					columnproperty(object_id(c.table_schema + '.' + c.table_name), c.column_name,'IsIdentity') as IsIdentity
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 										AND t.table_name = :table
82 82
 EOD;
83 83
 		if($schemaName!==null)
84
-			$sql .= ' AND t.table_schema = :schema';
84
+			$sql.=' AND t.table_schema = :schema';
85 85
 		if($catalogName!==null)
86
-			$sql .= ' AND t.table_catalog = :catalog';
86
+			$sql.=' AND t.table_catalog = :catalog';
87 87
 
88
-		$command = $this->getDbConnection()->createCommand($sql);
88
+		$command=$this->getDbConnection()->createCommand($sql);
89 89
 		$command->bindValue(':table', $tableName);
90 90
 		if($schemaName!==null)
91 91
 			$command->bindValue(':schema', $schemaName);
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 		foreach($command->query() as $col)
97 97
 		{
98 98
 			if($tableInfo===null)
99
-				$tableInfo = $this->createNewTableInfo($col);
100
-			$this->processColumn($tableInfo,$col);
99
+				$tableInfo=$this->createNewTableInfo($col);
100
+			$this->processColumn($tableInfo, $col);
101 101
 		}
102 102
 		if($tableInfo===null)
103 103
 			throw new TDbException('dbmetadata_invalid_table_view', $table);
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	protected function getCatalogSchemaTableName($table)
112 112
 	{
113 113
 		//remove possible delimiters
114
-		$result = explode('.', preg_replace('/\[|\]|"/', '', $table));
114
+		$result=explode('.', preg_replace('/\[|\]|"/', '', $table));
115 115
 		if(count($result)===1)
116
-			return array(null,null,$result[0]);
116
+			return array(null, null, $result[0]);
117 117
 		if(count($result)===2)
118
-			return array(null,$result[0],$result[1]);
119
-		if(count($result)>2)
120
-			return array($result[0],$result[1],$result[2]);
118
+			return array(null, $result[0], $result[1]);
119
+		if(count($result) > 2)
120
+			return array($result[0], $result[1], $result[2]);
121 121
 	}
122 122
 
123 123
 	/**
@@ -126,31 +126,31 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function processColumn($tableInfo, $col)
128 128
 	{
129
-		$columnId = $col['COLUMN_NAME'];
129
+		$columnId=$col['COLUMN_NAME'];
130 130
 
131
-		$info['ColumnName'] = "[$columnId]"; //quote the column names!
132
-		$info['ColumnId'] = $columnId;
133
-		$info['ColumnIndex'] = intval($col['ORDINAL_POSITION'])-1; //zero-based index
131
+		$info['ColumnName']="[$columnId]"; //quote the column names!
132
+		$info['ColumnId']=$columnId;
133
+		$info['ColumnIndex']=intval($col['ORDINAL_POSITION']) - 1; //zero-based index
134 134
 		if($col['IS_NULLABLE']!=='NO')
135
-			$info['AllowNull'] = true;
135
+			$info['AllowNull']=true;
136 136
 		if($col['COLUMN_DEFAULT']!==null)
137
-			$info['DefaultValue'] = $col['COLUMN_DEFAULT'];
137
+			$info['DefaultValue']=$col['COLUMN_DEFAULT'];
138 138
 
139 139
 		if(in_array($columnId, $tableInfo->getPrimaryKeys()))
140
-			$info['IsPrimaryKey'] = true;
140
+			$info['IsPrimaryKey']=true;
141 141
 		if($this->isForeignKeyColumn($columnId, $tableInfo))
142
-			$info['IsForeignKey'] = true;
142
+			$info['IsForeignKey']=true;
143 143
 
144 144
 		if($col['IsIdentity']==='1')
145
-			$info['AutoIncrement'] = true;
146
-		$info['DbType'] = $col['DATA_TYPE'];
145
+			$info['AutoIncrement']=true;
146
+		$info['DbType']=$col['DATA_TYPE'];
147 147
 		if($col['CHARACTER_MAXIMUM_LENGTH']!==null)
148
-			$info['ColumnSize'] = intval($col['CHARACTER_MAXIMUM_LENGTH']);
149
-		if($col['NUMERIC_PRECISION'] !== null)
150
-			$info['NumericPrecision'] = intval($col['NUMERIC_PRECISION']);
148
+			$info['ColumnSize']=intval($col['CHARACTER_MAXIMUM_LENGTH']);
149
+		if($col['NUMERIC_PRECISION']!==null)
150
+			$info['NumericPrecision']=intval($col['NUMERIC_PRECISION']);
151 151
 		if($col['NUMERIC_SCALE']!==null)
152
-			$info['NumericScale'] = intval($col['NUMERIC_SCALE']);
153
-		$tableInfo->Columns[$columnId] = new TMssqlTableColumn($info);
152
+			$info['NumericScale']=intval($col['NUMERIC_SCALE']);
153
+		$tableInfo->Columns[$columnId]=new TMssqlTableColumn($info);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	protected function createNewTableInfo($col)
162 162
 	{
163
-		$info['CatalogName'] = $col['TABLE_CATALOG'];
164
-		$info['SchemaName'] = $col['TABLE_SCHEMA'];
165
-		$info['TableName'] = $col['TABLE_NAME'];
163
+		$info['CatalogName']=$col['TABLE_CATALOG'];
164
+		$info['SchemaName']=$col['TABLE_SCHEMA'];
165
+		$info['TableName']=$col['TABLE_NAME'];
166 166
 		if($col['TABLE_TYPE']==='VIEW')
167
-			$info['IsView'] = true;
168
-		list($primary, $foreign) = $this->getConstraintKeys($col);
169
-		$class = $this->getTableInfoClass();
170
-		return new $class($info,$primary,$foreign);
167
+			$info['IsView']=true;
168
+		list($primary, $foreign)=$this->getConstraintKeys($col);
169
+		$class=$this->getTableInfoClass();
170
+		return new $class($info, $primary, $foreign);
171 171
 	}
172 172
 
173 173
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	protected function getConstraintKeys($col)
180 180
 	{
181
-		$sql = <<<EOD
181
+		$sql=<<<EOD
182 182
 		SELECT k.column_name field_name
183 183
 				FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE k
184 184
 				LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS c
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 			c.constraint_type ='PRIMARY KEY'
190 190
 				AND k.table_name = :table
191 191
 EOD;
192
-		$command = $this->getDbConnection()->createCommand($sql);
192
+		$command=$this->getDbConnection()->createCommand($sql);
193 193
 		$command->bindValue(':table', $col['TABLE_NAME']);
194
-		$primary = array();
194
+		$primary=array();
195 195
 		foreach($command->query()->readAll() as $field)
196
-			$primary[] = $field['field_name'];
197
-		$foreign = $this->getForeignConstraints($col);
198
-		return array($primary,$foreign);
196
+			$primary[]=$field['field_name'];
197
+		$foreign=$this->getForeignConstraints($col);
198
+		return array($primary, $foreign);
199 199
 	}
200 200
 
201 201
 	/**
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	protected function getForeignConstraints($col)
208 208
 	{
209 209
 		//From http://msdn2.microsoft.com/en-us/library/aa175805(SQL.80).aspx
210
-		$sql = <<<EOD
210
+		$sql=<<<EOD
211 211
 		SELECT
212 212
 				KCU1.CONSTRAINT_NAME AS 'FK_CONSTRAINT_NAME'
213 213
 			, KCU1.TABLE_NAME AS 'FK_TABLE_NAME'
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
 			AND KCU2.ORDINAL_POSITION = KCU1.ORDINAL_POSITION
233 233
 		WHERE KCU1.TABLE_NAME = :table
234 234
 EOD;
235
-		$command = $this->getDbConnection()->createCommand($sql);
235
+		$command=$this->getDbConnection()->createCommand($sql);
236 236
 		$command->bindValue(':table', $col['TABLE_NAME']);
237 237
 		$fkeys=array();
238
-		$catalogSchema = "[{$col['TABLE_CATALOG']}].[{$col['TABLE_SCHEMA']}]";
238
+		$catalogSchema="[{$col['TABLE_CATALOG']}].[{$col['TABLE_SCHEMA']}]";
239 239
 		foreach($command->query() as $info)
240 240
 		{
241
-			$fkeys[$info['FK_CONSTRAINT_NAME']]['keys'][$info['FK_COLUMN_NAME']] = $info['UQ_COLUMN_NAME'];
242
-			$fkeys[$info['FK_CONSTRAINT_NAME']]['table'] = $info['UQ_TABLE_NAME'];
241
+			$fkeys[$info['FK_CONSTRAINT_NAME']]['keys'][$info['FK_COLUMN_NAME']]=$info['UQ_COLUMN_NAME'];
242
+			$fkeys[$info['FK_CONSTRAINT_NAME']]['table']=$info['UQ_TABLE_NAME'];
243 243
 		}
244 244
 		return count($fkeys) > 0 ? array_values($fkeys) : $fkeys;
245 245
 	}
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 		$command->bindParam(":schema", $schema);
277 277
 		$rows=$command->queryAll();
278 278
 		$names=array();
279
-		foreach ($rows as $row)
279
+		foreach($rows as $row)
280 280
 		{
281
-			if ($schema == self::DEFAULT_SCHEMA)
281
+			if($schema==self::DEFAULT_SCHEMA)
282 282
 				$names[]=$row['TABLE_NAME'];
283 283
 			else
284 284
 				$names[]=$schema.'.'.$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME'];
Please login to merge, or discard this patch.
framework/Data/Common/Mssql/TMssqlTableColumn.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
 	/**
29 29
 	 * Overrides parent implementation, returns PHP type from the db type.
30
-	 * @return boolean derived PHP primitive type from the column db type.
30
+	 * @return string derived PHP primitive type from the column db type.
31 31
 	 */
32 32
 	public function getPHPType()
33 33
 	{
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class TMssqlTableColumn extends TDbTableColumn
25 25
 {
26
-	private static $types = array();
26
+	private static $types=array();
27 27
 
28 28
 	/**
29 29
 	 * Overrides parent implementation, returns PHP type from the db type.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getAutoIncrement()
42 42
 	{
43
-		return $this->getInfo('AutoIncrement',false);
43
+		return $this->getInfo('AutoIncrement', false);
44 44
 	}
45 45
 
46 46
 	/**
Please login to merge, or discard this patch.
framework/Data/Common/Mysql/TMysqlMetaData.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -114,6 +114,7 @@
 block discarded – undo
114 114
 	/**
115 115
 	 * @param TMysqlTableInfo table information.
116 116
 	 * @param array column information.
117
+	 * @param TMysqlTableInfo $tableInfo
117 118
 	 */
118 119
 	protected function processColumn($tableInfo, $col)
119 120
 	{
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -417,12 +417,12 @@
 block discarded – undo
417 417
 		return false;
418 418
 	}
419 419
 
420
-        /**
421
-	 * Returns all table names in the database.
422
-	 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
423
-	 * If not empty, the returned table names will be prefixed with the schema name.
424
-	 * @return array all table names in the database.
425
-	 */
420
+		/**
421
+		 * Returns all table names in the database.
422
+		 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
423
+		 * If not empty, the returned table names will be prefixed with the schema name.
424
+		 * @return array all table names in the database.
425
+		 */
426 426
 	public function findTableNames($schema='public')
427 427
 	{
428 428
 		if($schema==='')
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	protected function createTableInfo($table)
76 76
 	{
77
-		list($schemaName,$tableName) = $this->getSchemaTableName($table);
78
-		$find = $schemaName===null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`";
79
-		$colCase = $this->getDbConnection()->getColumnCase();
80
-		if($colCase != TDbColumnCaseMode::Preserved)
77
+		list($schemaName, $tableName)=$this->getSchemaTableName($table);
78
+		$find=$schemaName===null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`";
79
+		$colCase=$this->getDbConnection()->getColumnCase();
80
+		if($colCase!=TDbColumnCaseMode::Preserved)
81 81
 			$this->getDbConnection()->setColumnCase('Preserved');
82 82
 		$this->getDbConnection()->setActive(true);
83
-		$sql = "SHOW FULL FIELDS FROM {$find}";
84
-		$command = $this->getDbConnection()->createCommand($sql);
85
-		$tableInfo = $this->createNewTableInfo($table);
83
+		$sql="SHOW FULL FIELDS FROM {$find}";
84
+		$command=$this->getDbConnection()->createCommand($sql);
85
+		$tableInfo=$this->createNewTableInfo($table);
86 86
 		$index=0;
87 87
 		foreach($command->query() as $col)
88 88
 		{
89
-			$col['index'] = $index++;
90
-			$this->processColumn($tableInfo,$col);
89
+			$col['index']=$index++;
90
+			$this->processColumn($tableInfo, $col);
91 91
 		}
92 92
 		if($index===0)
93 93
 			throw new TDbException('dbmetadata_invalid_table_view', $table);
94
-		if($colCase != TDbColumnCaseMode::Preserved)
94
+		if($colCase!=TDbColumnCaseMode::Preserved)
95 95
 			$this->getDbConnection()->setColumnCase($colCase);
96 96
 		return $tableInfo;
97 97
 	}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	{
104 104
 		if(!$this->_serverVersion)
105 105
 		{
106
-			$version = $this->getDbConnection()->getAttribute(PDO::ATTR_SERVER_VERSION);
106
+			$version=$this->getDbConnection()->getAttribute(PDO::ATTR_SERVER_VERSION);
107 107
 			$digits=array();
108 108
 			preg_match('/(\d+)\.(\d+)\.(\d+)/', $version, $digits);
109 109
 			$this->_serverVersion=floatval($digits[1].'.'.$digits[2].$digits[3]);
@@ -117,50 +117,50 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function processColumn($tableInfo, $col)
119 119
 	{
120
-		$columnId = $col['Field'];
120
+		$columnId=$col['Field'];
121 121
 
122
-		$info['ColumnName'] = "`$columnId`"; //quote the column names!
123
-		$info['ColumnId'] = $columnId;
124
-		$info['ColumnIndex'] = $col['index'];
122
+		$info['ColumnName']="`$columnId`"; //quote the column names!
123
+		$info['ColumnId']=$columnId;
124
+		$info['ColumnIndex']=$col['index'];
125 125
 		if($col['Null']==='YES')
126
-			$info['AllowNull'] = true;
126
+			$info['AllowNull']=true;
127 127
 		if(is_int(strpos(strtolower($col['Extra']), 'auto_increment')))
128 128
 			$info['AutoIncrement']=true;
129 129
 		if($col['Default']!=="")
130
-			$info['DefaultValue'] = $col['Default'];
130
+			$info['DefaultValue']=$col['Default'];
131 131
 
132 132
 		if($col['Key']==='PRI' || in_array($columnId, $tableInfo->getPrimaryKeys()))
133
-			$info['IsPrimaryKey'] = true;
133
+			$info['IsPrimaryKey']=true;
134 134
 		if($this->isForeignKeyColumn($columnId, $tableInfo))
135
-			$info['IsForeignKey'] = true;
135
+			$info['IsForeignKey']=true;
136 136
 
137
-		$info['DbType'] = $col['Type'];
137
+		$info['DbType']=$col['Type'];
138 138
 		$match=array();
139 139
 		//find SET/ENUM values, column size, precision, and scale
140 140
 		if(preg_match('/\((.*)\)/', $col['Type'], $match))
141 141
 		{
142
-			$info['DbType']= preg_replace('/\(.*\)/', '', $col['Type']);
142
+			$info['DbType']=preg_replace('/\(.*\)/', '', $col['Type']);
143 143
 
144 144
 			//find SET/ENUM values
145 145
 			if($this->isEnumSetType($info['DbType']))
146
-				$info['DbTypeValues'] = preg_split("/[',]/S", $match[1], -1, PREG_SPLIT_NO_EMPTY);
146
+				$info['DbTypeValues']=preg_split("/[',]/S", $match[1], -1, PREG_SPLIT_NO_EMPTY);
147 147
 
148 148
 			//find column size, precision and scale
149
-			$pscale = array();
149
+			$pscale=array();
150 150
 			if(preg_match('/(\d+)(?:,(\d+))?+/', $match[1], $pscale))
151 151
 			{
152 152
 				if($this->isPrecisionType($info['DbType']))
153 153
 				{
154
-					$info['NumericPrecision'] = intval($pscale[1]);
154
+					$info['NumericPrecision']=intval($pscale[1]);
155 155
 					if(count($pscale) > 2)
156
-						$info['NumericScale'] = intval($pscale[2]);
156
+						$info['NumericScale']=intval($pscale[2]);
157 157
 				}
158 158
 				else
159
-					$info['ColumnSize'] = intval($pscale[1]);
159
+					$info['ColumnSize']=intval($pscale[1]);
160 160
 			}
161 161
 		}
162 162
 
163
-		$tableInfo->Columns[$columnId] = new TMysqlTableColumn($info);
163
+		$tableInfo->Columns[$columnId]=new TMysqlTableColumn($info);
164 164
 	}
165 165
 
166 166
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function isPrecisionType($type)
170 170
 	{
171
-		$type = strtolower(trim($type));
171
+		$type=strtolower(trim($type));
172 172
 		return $type==='decimal' || $type==='dec'
173 173
 				|| $type==='float' || $type==='double'
174 174
 				|| $type==='double precision' || $type==='real';
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	protected function isEnumSetType($type)
181 181
 	{
182
-		$type = strtolower(trim($type));
182
+		$type=strtolower(trim($type));
183 183
 		return $type==='set' || $type==='enum';
184 184
 	}
185 185
 
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 	protected function getSchemaTableName($table)
192 192
 	{
193 193
 		//remove the back ticks and separate out the "database.table"
194
-		$result = explode('.', str_replace('`', '', $table));
194
+		$result=explode('.', str_replace('`', '', $table));
195 195
 		foreach($result as $name)
196 196
 		{
197 197
 			if(!$this->isValidIdentifier($name))
198 198
 			{
199
-				$ref = 'http://dev.mysql.com/doc/refman/5.0/en/identifiers.html';
199
+				$ref='http://dev.mysql.com/doc/refman/5.0/en/identifiers.html';
200 200
 				throw new TDbException('dbcommon_invalid_identifier_name', $table, $ref);
201 201
 			}
202 202
 		}
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	protected function createNewTableInfo($table)
222 222
 	{
223
-		list($schemaName,$tableName) = $this->getSchemaTableName($table);
224
-		$info['SchemaName'] = $schemaName;
225
-		$info['TableName'] = $tableName;
226
-		if($this->getIsView($schemaName,$tableName))
227
-			$info['IsView'] = true;
228
-		list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName);
229
-		$class = $this->getTableInfoClass();
230
-		return new $class($info,$primary,$foreign);
223
+		list($schemaName, $tableName)=$this->getSchemaTableName($table);
224
+		$info['SchemaName']=$schemaName;
225
+		$info['TableName']=$tableName;
226
+		if($this->getIsView($schemaName, $tableName))
227
+			$info['IsView']=true;
228
+		list($primary, $foreign)=$this->getConstraintKeys($schemaName, $tableName);
229
+		$class=$this->getTableInfoClass();
230
+		return new $class($info, $primary, $foreign);
231 231
 	}
232 232
 
233 233
 	/**
@@ -240,25 +240,25 @@  discard block
 block discarded – undo
240 240
 	 * @return boolean true if is view, false otherwise.
241 241
 	 * @throws TDbException if table or view does not exist.
242 242
 	 */
243
-	protected function getIsView($schemaName,$tableName)
243
+	protected function getIsView($schemaName, $tableName)
244 244
 	{
245
-		if($this->getServerVersion()<5.01)
245
+		if($this->getServerVersion() < 5.01)
246 246
 			return false;
247 247
 		if($schemaName!==null)
248
-			$sql = "SHOW FULL TABLES FROM `{$schemaName}` LIKE :table";
248
+			$sql="SHOW FULL TABLES FROM `{$schemaName}` LIKE :table";
249 249
 		else
250
-			$sql = "SHOW FULL TABLES LIKE :table";
250
+			$sql="SHOW FULL TABLES LIKE :table";
251 251
 
252
-		$command = $this->getDbConnection()->createCommand($sql);
252
+		$command=$this->getDbConnection()->createCommand($sql);
253 253
 		$command->bindValue(':table', $tableName);
254 254
 		try
255 255
 		{
256
-			return count($result = $command->queryRow()) > 0 && $result['Table_type']==='VIEW';
256
+			return count($result=$command->queryRow()) > 0 && $result['Table_type']==='VIEW';
257 257
 		}
258 258
 		catch(TDbException $e)
259 259
 		{
260
-			$table = $schemaName===null?$tableName:$schemaName.'.'.$tableName;
261
-			throw new TDbException('dbcommon_invalid_table_name',$table,$e->getMessage());
260
+			$table=$schemaName===null ? $tableName : $schemaName.'.'.$tableName;
261
+			throw new TDbException('dbcommon_invalid_table_name', $table, $e->getMessage());
262 262
 		}
263 263
 	}
264 264
 
@@ -270,22 +270,22 @@  discard block
 block discarded – undo
270 270
 	 */
271 271
 	protected function getConstraintKeys($schemaName, $tableName)
272 272
 	{
273
-		$table = $schemaName===null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`";
274
-		$sql = "SHOW INDEX FROM {$table}";
275
-		$command = $this->getDbConnection()->createCommand($sql);
276
-		$primary = array();
273
+		$table=$schemaName===null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`";
274
+		$sql="SHOW INDEX FROM {$table}";
275
+		$command=$this->getDbConnection()->createCommand($sql);
276
+		$primary=array();
277 277
 		foreach($command->query() as $row)
278 278
 		{
279 279
 			if($row['Key_name']==='PRIMARY')
280
-				$primary[] = $row['Column_name'];
280
+				$primary[]=$row['Column_name'];
281 281
 		}
282 282
 				// MySQL version was increased to >=5.1.21 instead of 5.x
283 283
 				// due to a MySQL bug (http://bugs.mysql.com/bug.php?id=19588)
284 284
 		if($this->getServerVersion() >= 5.121)
285
-			$foreign = $this->getForeignConstraints($schemaName,$tableName);
285
+			$foreign=$this->getForeignConstraints($schemaName, $tableName);
286 286
 		else
287
-			$foreign = $this->findForeignConstraints($schemaName,$tableName);
288
-		return array($primary,$foreign);
287
+			$foreign=$this->findForeignConstraints($schemaName, $tableName);
288
+		return array($primary, $foreign);
289 289
 	}
290 290
 
291 291
 	/**
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	protected function getForeignConstraints($schemaName, $tableName)
298 298
 	{
299
-		$andSchema = $schemaName !== null ? 'AND TABLE_SCHEMA LIKE :schema' : 'AND TABLE_SCHEMA LIKE DATABASE()';
300
-		$sql = <<<EOD
299
+		$andSchema=$schemaName!==null ? 'AND TABLE_SCHEMA LIKE :schema' : 'AND TABLE_SCHEMA LIKE DATABASE()';
300
+		$sql=<<<EOD
301 301
 			SELECT
302 302
 				CONSTRAINT_NAME as con,
303 303
 				COLUMN_NAME as col,
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 				AND TABLE_NAME LIKE :table
312 312
 				$andSchema
313 313
 EOD;
314
-		$command = $this->getDbConnection()->createCommand($sql);
314
+		$command=$this->getDbConnection()->createCommand($sql);
315 315
 		$command->bindValue(':table', $tableName);
316 316
 		if($schemaName!==null)
317 317
 			$command->bindValue(':schema', $schemaName);
318 318
 		$fkeys=array();
319 319
 		foreach($command->query() as $col)
320 320
 		{
321
-			$fkeys[$col['con']]['keys'][$col['col']] = $col['fkcol'];
322
-			$fkeys[$col['con']]['table'] = $col['fktable'];
321
+			$fkeys[$col['con']]['keys'][$col['col']]=$col['fkcol'];
322
+			$fkeys[$col['con']]['table']=$col['fktable'];
323 323
 		}
324 324
 		return count($fkeys) > 0 ? array_values($fkeys) : $fkeys;
325 325
 	}
@@ -332,17 +332,17 @@  discard block
 block discarded – undo
332 332
 	 */
333 333
 	protected function getShowCreateTable($schemaName, $tableName)
334 334
 	{
335
-		if(version_compare(PHP_VERSION,'5.1.3','<'))
335
+		if(version_compare(PHP_VERSION, '5.1.3', '<'))
336 336
 			throw new TDbException('dbmetadata_requires_php_version', 'Mysql 4.1.x', '5.1.3');
337 337
 
338 338
 		//See http://netevil.org/node.php?nid=795&SC=1
339 339
 		$this->getDbConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
340 340
 		if($schemaName!==null)
341
-			$sql = "SHOW CREATE TABLE `{$schemaName}`.`{$tableName}`";
341
+			$sql="SHOW CREATE TABLE `{$schemaName}`.`{$tableName}`";
342 342
 		else
343
-			$sql = "SHOW CREATE TABLE `{$tableName}`";
344
-		$command = $this->getDbConnection()->createCommand($sql);
345
-		$result = $command->queryRow();
343
+			$sql="SHOW CREATE TABLE `{$tableName}`";
344
+		$command=$this->getDbConnection()->createCommand($sql);
345
+		$result=$command->queryRow();
346 346
 		return isset($result['Create Table']) ? $result['Create Table'] : (isset($result['Create View']) ? $result['Create View'] : '');
347 347
 	}
348 348
 
@@ -354,19 +354,19 @@  discard block
 block discarded – undo
354 354
 	 */
355 355
 	protected function findForeignConstraints($schemaName, $tableName)
356 356
 	{
357
-		$sql = $this->getShowCreateTable($schemaName, $tableName);
358
-		$matches =array();
359
-		$regexp = '/FOREIGN KEY\s+\(([^\)]+)\)\s+REFERENCES\s+`?([^`]+)`?\s\(([^\)]+)\)/mi';
360
-		preg_match_all($regexp,$sql,$matches,PREG_SET_ORDER);
361
-		$foreign = array();
357
+		$sql=$this->getShowCreateTable($schemaName, $tableName);
358
+		$matches=array();
359
+		$regexp='/FOREIGN KEY\s+\(([^\)]+)\)\s+REFERENCES\s+`?([^`]+)`?\s\(([^\)]+)\)/mi';
360
+		preg_match_all($regexp, $sql, $matches, PREG_SET_ORDER);
361
+		$foreign=array();
362 362
 		foreach($matches as $match)
363 363
 		{
364
-			$fields = array_map('trim',explode(',',str_replace('`','',$match[1])));
365
-			$fk_fields = array_map('trim',explode(',',str_replace('`','',$match[3])));
364
+			$fields=array_map('trim', explode(',', str_replace('`', '', $match[1])));
365
+			$fk_fields=array_map('trim', explode(',', str_replace('`', '', $match[3])));
366 366
 			$keys=array();
367 367
 			foreach($fields as $k=>$v)
368
-				$keys[$v] = $fk_fields[$k];
369
-			$foreign[] = array('keys' => $keys, 'table' => trim($match[2]));
368
+				$keys[$v]=$fk_fields[$k];
369
+			$foreign[]=array('keys' => $keys, 'table' => trim($match[2]));
370 370
 		}
371 371
 		return $foreign;
372 372
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -154,8 +154,7 @@  discard block
 block discarded – undo
154 154
 					$info['NumericPrecision'] = intval($pscale[1]);
155 155
 					if(count($pscale) > 2)
156 156
 						$info['NumericScale'] = intval($pscale[2]);
157
-				}
158
-				else
157
+				} else
159 158
 					$info['ColumnSize'] = intval($pscale[1]);
160 159
 			}
161 160
 		}
@@ -254,8 +253,7 @@  discard block
 block discarded – undo
254 253
 		try
255 254
 		{
256 255
 			return count($result = $command->queryRow()) > 0 && $result['Table_type']==='VIEW';
257
-		}
258
-		catch(TDbException $e)
256
+		} catch(TDbException $e)
259 257
 		{
260 258
 			$table = $schemaName===null?$tableName:$schemaName.'.'.$tableName;
261 259
 			throw new TDbException('dbcommon_invalid_table_name',$table,$e->getMessage());
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleMetaData.php 4 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	/**
146 146
 	 * @param string table schema name
147 147
 	 * @param string table name.
148
-	 * @return boolean true if the table is a view.
148
+	 * @return integer true if the table is a view.
149 149
 	 */
150 150
 	protected function getIsView($schemaName,$tableName)
151 151
 	{
@@ -167,6 +167,7 @@  discard block
 block discarded – undo
167 167
 	/**
168 168
 	 * @param TOracleTableInfo table information.
169 169
 	 * @param array column information.
170
+	 * @param TOracleTableInfo $tableInfo
170 171
 	 */
171 172
 	protected function processColumn($tableInfo, $col)
172 173
 	{
@@ -322,6 +323,7 @@  discard block
 block discarded – undo
322 323
 	/**
323 324
 	 * @param string column name.
324 325
 	 * @param TOracleTableInfo table information.
326
+	 * @param string $columnId
325 327
 	 * @return boolean true if column is a foreign key.
326 328
 	 */
327 329
 	protected function isForeignKeyColumn($columnId, $tableInfo)
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -417,12 +417,12 @@
 block discarded – undo
417 417
 		return false;
418 418
 	}
419 419
 
420
-        /**
421
-	 * Returns all table names in the database.
422
-	 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
423
-	 * If not empty, the returned table names will be prefixed with the schema name.
424
-	 * @return array all table names in the database.
425
-	 */
420
+		/**
421
+		 * Returns all table names in the database.
422
+		 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
423
+		 * If not empty, the returned table names will be prefixed with the schema name.
424
+		 * @return array all table names in the database.
425
+		 */
426 426
 	public function findTableNames($schema='public')
427 427
 	{
428 428
 		if($schema==='')
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class TOracleMetaData extends TDbMetaData
27 27
 {
28
-	private $_defaultSchema = 'system';
28
+	private $_defaultSchema='system';
29 29
 
30 30
 
31 31
 	/**
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	protected function getSchemaTableName($table)
60 60
 	{
61
-		if(count($parts= explode('.', str_replace('"','',$table))) > 1)
61
+		if(count($parts=explode('.', str_replace('"', '', $table))) > 1)
62 62
 			return array($parts[0], $parts[1]);
63 63
 		else
64
-			return array($this->getDefaultSchema(),$parts[0]);
64
+			return array($this->getDefaultSchema(), $parts[0]);
65 65
 	}
66 66
 
67 67
 	/**
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	protected function createTableInfo($table)
73 73
 	{
74
-		list($schemaName,$tableName) = $this->getSchemaTableName($table);
74
+		list($schemaName, $tableName)=$this->getSchemaTableName($table);
75 75
 
76 76
 		// This query is made much more complex by the addition of the 'attisserial' field.
77 77
 		// The subquery to get that field checks to see if there is an internally dependent
78 78
 		// sequence on the field.
79
-		$sql =
79
+		$sql=
80 80
 <<<EOD
81 81
 		SELECT
82 82
 			a.COLUMN_ID,
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 EOD;
97 97
 		$this->getDbConnection()->setActive(true);
98 98
 		$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
99
-		$command = $this->getDbConnection()->createCommand($sql);
99
+		$command=$this->getDbConnection()->createCommand($sql);
100 100
 		//$command->bindValue(':table', $tableName);
101 101
 		//$command->bindValue(':schema', $schemaName);
102
-		$tableInfo = $this->createNewTableInfo($schemaName, $tableName);
102
+		$tableInfo=$this->createNewTableInfo($schemaName, $tableName);
103 103
 		$index=0;
104 104
 		foreach($command->query() as $col)
105 105
 		{
106
-			$col['index'] = $index++;
106
+			$col['index']=$index++;
107 107
 			$this->processColumn($tableInfo, $col);
108 108
 		}
109 109
 		if($index===0)
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 	 * @param string table name.
117 117
 	 * @return TOracleTableInfo
118 118
 	 */
119
-	protected function createNewTableInfo($schemaName,$tableName)
119
+	protected function createNewTableInfo($schemaName, $tableName)
120 120
 	{
121
-		$info['SchemaName'] = $this->assertIdentifier($schemaName);
122
-		$info['TableName']	= $this->assertIdentifier($tableName);
123
-		$info['IsView'] 	= false;
124
-		if($this->getIsView($schemaName,$tableName)) $info['IsView'] = true;
125
-		list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName);
126
-		$class = $this->getTableInfoClass();
127
-		return new $class($info,$primary,$foreign);
121
+		$info['SchemaName']=$this->assertIdentifier($schemaName);
122
+		$info['TableName']=$this->assertIdentifier($tableName);
123
+		$info['IsView']=false;
124
+		if($this->getIsView($schemaName, $tableName)) $info['IsView']=true;
125
+		list($primary, $foreign)=$this->getConstraintKeys($schemaName, $tableName);
126
+		$class=$this->getTableInfoClass();
127
+		return new $class($info, $primary, $foreign);
128 128
 	}
129 129
 
130 130
 	/**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	{
137 137
 		if(strpos($name, '"')!==false)
138 138
 		{
139
-			$ref = 'http://www.oracle.com';
139
+			$ref='http://www.oracle.com';
140 140
 			throw new TDbException('dbcommon_invalid_identifier_name', $name, $ref);
141 141
 		}
142 142
 		return $name;
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 	 * @param string table name.
148 148
 	 * @return boolean true if the table is a view.
149 149
 	 */
150
-	protected function getIsView($schemaName,$tableName)
150
+	protected function getIsView($schemaName, $tableName)
151 151
 	{
152 152
 		$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
153
-		$sql =
153
+		$sql=
154 154
 <<<EOD
155 155
 		select	OBJECT_TYPE
156 156
 		from 	ALL_OBJECTS
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 		and 	OWNER = '{$schemaName}'
159 159
 EOD;
160 160
 		$this->getDbConnection()->setActive(true);
161
-		$command = $this->getDbConnection()->createCommand($sql);
161
+		$command=$this->getDbConnection()->createCommand($sql);
162 162
 		//$command->bindValue(':schema',$schemaName);
163 163
 		//$command->bindValue(':table', $tableName);
164
-		return intval($command->queryScalar() === 'VIEW');
164
+		return intval($command->queryScalar()==='VIEW');
165 165
 	}
166 166
 
167 167
 	/**
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	protected function processColumn($tableInfo, $col)
172 172
 	{
173
-		$columnId = strtolower($col['attname']); //use column name as column Id
173
+		$columnId=strtolower($col['attname']); //use column name as column Id
174 174
 
175 175
 		//$info['ColumnName'] 	= '"'.$columnId.'"'; //quote the column names!
176
-		$info['ColumnName'] 	= $columnId; //NOT quote the column names!
177
-		$info['ColumnId'] 		= $columnId;
178
-		$info['ColumnIndex'] 	= $col['index'];
179
-		if(! (bool)$col['attnotnull'] ) $info['AllowNull'] = true;
180
-		if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey'] = true;
181
-		if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey'] = true;
182
-		if( (int)$col['atttypmod'] > 0 ) $info['ColumnSize'] =  $col['atttypmod']; // - 4;
183
-		if( (bool)$col['atthasdef'] ) $info['DefaultValue'] = $col['adsrc'];
176
+		$info['ColumnName']=$columnId; //NOT quote the column names!
177
+		$info['ColumnId']=$columnId;
178
+		$info['ColumnIndex']=$col['index'];
179
+		if(!(bool) $col['attnotnull']) $info['AllowNull']=true;
180
+		if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey']=true;
181
+		if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey']=true;
182
+		if((int) $col['atttypmod'] > 0) $info['ColumnSize']=$col['atttypmod']; // - 4;
183
+		if((bool) $col['atthasdef']) $info['DefaultValue']=$col['adsrc'];
184 184
 		//
185 185
 		// For a while Oracle Tables has no  associated AutoIncrement Triggers
186 186
 		//
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 			}
195 195
 		}
196 196
 		*/
197
-		$matches = array();
197
+		$matches=array();
198 198
 		if(preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches))
199 199
 		{
200
-			$info['DbType'] = preg_replace('/\(\d+(?:,\d+)?\)/','',$col['type']);
200
+			$info['DbType']=preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']);
201 201
 			if($this->isPrecisionType($info['DbType']))
202 202
 			{
203
-				$info['NumericPrecision'] = intval($matches[1]);
203
+				$info['NumericPrecision']=intval($matches[1]);
204 204
 				if(count($matches) > 2)
205
-					$info['NumericScale'] = intval($matches[2]);
205
+					$info['NumericScale']=intval($matches[2]);
206 206
 			}
207 207
 			else
208
-				$info['ColumnSize'] = intval($matches[1]);
208
+				$info['ColumnSize']=intval($matches[1]);
209 209
 		}
210 210
 		else
211
-			$info['DbType'] = $col['type'];
212
-		$tableInfo->Columns[$columnId] = new TOracleTableColumn($info);
211
+			$info['DbType']=$col['type'];
212
+		$tableInfo->Columns[$columnId]=new TOracleTableColumn($info);
213 213
 	}
214 214
 
215 215
 	/**
216 216
 	 * @return string serial name if found, null otherwise.
217 217
 	 */
218
-	protected function getSequenceName($tableInfo,$src)
218
+	protected function getSequenceName($tableInfo, $src)
219 219
 	{
220
-		$matches = array();
221
-		if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i',$src,$matches))
220
+		$matches=array();
221
+		if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches))
222 222
 		{
223 223
 			if(is_int(strpos($matches[1], '.')))
224 224
 				return $matches[1];
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	protected function isPrecisionType($type)
234 234
 	{
235
-		$type = strtolower(trim($type));
235
+		$type=strtolower(trim($type));
236 236
 		return $type==='number'; // || $type==='interval' || strpos($type, 'time')===0;
237 237
 	}
238 238
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	{
247 247
 		$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
248 248
 //		select decode( a.CONSTRAINT_TYPE, 'P', 'PRIMARY KEY (', 'FOREIGN KEY (' )||b.COLUMN_NAME||')' as consrc,
249
-		$sql =
249
+		$sql=
250 250
 <<<EOD
251 251
 		select b.COLUMN_NAME as consrc,
252 252
 			   a.CONSTRAINT_TYPE as contype
@@ -257,24 +257,24 @@  discard block
 block discarded – undo
257 257
 		and   a.CONSTRAINT_TYPE in ('P','R')
258 258
 EOD;
259 259
 		$this->getDbConnection()->setActive(true);
260
-		$command = $this->getDbConnection()->createCommand($sql);
260
+		$command=$this->getDbConnection()->createCommand($sql);
261 261
 		//$command->bindValue(':table', $tableName);
262 262
 		//$command->bindValue(':schema', $schemaName);
263
-		$primary = array();
264
-		$foreign = array();
263
+		$primary=array();
264
+		$foreign=array();
265 265
 		foreach($command->query() as $row)
266 266
 		{
267
-			switch( strtolower( $row['contype'] ) )
267
+			switch(strtolower($row['contype']))
268 268
 			{
269 269
 				case 'p':
270
-					$primary = array_merge( $primary, array(strtolower( $row['consrc'] )) );
270
+					$primary=array_merge($primary, array(strtolower($row['consrc'])));
271 271
 					/*
272 272
 					$arr = $this->getPrimaryKeys($row['consrc']);
273 273
 					$primary = array_merge( $primary, array(strtolower( $arr[0] )) );
274 274
 					*/
275 275
 					break;
276 276
 				case 'r':
277
-					$foreign = array_merge( $foreign, array(strtolower( $row['consrc'] )) );
277
+					$foreign=array_merge($foreign, array(strtolower($row['consrc'])));
278 278
 					/*
279 279
 					// if(($fkey = $this->getForeignKeys($row['consrc']))!==null)
280 280
 					$fkey = $this->getForeignKeys( $row['consrc'] );
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 					break;
284 284
 			}
285 285
 		}
286
-		return array($primary,$foreign);
286
+		return array($primary, $foreign);
287 287
 	}
288 288
 
289 289
 	/**
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	protected function getPrimaryKeys($src)
295 295
 	{
296
-		$matches = array();
296
+		$matches=array();
297 297
 		if(preg_match('/PRIMARY\s+KEY\s+\(([^\)]+)\)/i', $src, $matches))
298
-			return preg_split('/,\s+/',$matches[1]);
298
+			return preg_split('/,\s+/', $matches[1]);
299 299
 		return array();
300 300
 	}
301 301
 
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	protected function getForeignKeys($src)
308 308
 	{
309
-		$matches = array();
310
-		$brackets = '\(([^\)]+)\)';
311
-		$find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
309
+		$matches=array();
310
+		$brackets='\(([^\)]+)\)';
311
+		$find="/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
312 312
 		if(preg_match($find, $src, $matches))
313 313
 		{
314
-			$keys = preg_split('/,\s+/', $matches[1]);
315
-			$fkeys = array();
314
+			$keys=preg_split('/,\s+/', $matches[1]);
315
+			$fkeys=array();
316 316
 			foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey)
317
-				$fkeys[$keys[$i]] = $fkey;
318
-			return array('table' => str_replace('"','',$matches[2]), 'keys' => $fkeys);
317
+				$fkeys[$keys[$i]]=$fkey;
318
+			return array('table' => str_replace('"', '', $matches[2]), 'keys' => $fkeys);
319 319
 		}
320 320
 	}
321 321
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	{
329 329
 		foreach($tableInfo->getForeignKeys() as $fk)
330 330
 		{
331
-			if( $fk==$columnId )
331
+			if($fk==$columnId)
332 332
 			//if(in_array($columnId, array_keys($fk['keys'])))
333 333
 				return true;
334 334
 		}
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 WHERE object_type = 'TABLE' AND owner=:schema
358 358
 EOD;
359 359
 			$command=$this->getDbConnection()->createCommand($sql);
360
-			$command->bindParam(':schema',$schema);
360
+			$command->bindParam(':schema', $schema);
361 361
 		}
362 362
 
363 363
 		$rows=$command->queryAll();
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -203,11 +203,9 @@  discard block
 block discarded – undo
203 203
 				$info['NumericPrecision'] = intval($matches[1]);
204 204
 				if(count($matches) > 2)
205 205
 					$info['NumericScale'] = intval($matches[2]);
206
-			}
207
-			else
206
+			} else
208 207
 				$info['ColumnSize'] = intval($matches[1]);
209
-		}
210
-		else
208
+		} else
211 209
 			$info['DbType'] = $col['type'];
212 210
 		$tableInfo->Columns[$columnId] = new TOracleTableColumn($info);
213 211
 	}
@@ -349,8 +347,7 @@  discard block
 block discarded – undo
349 347
 SELECT table_name, '{$schema}' as table_schema FROM user_tables
350 348
 EOD;
351 349
 			$command=$this->getDbConnection()->createCommand($sql);
352
-		}
353
-		else
350
+		} else
354 351
 		{
355 352
 			$sql=<<<EOD
356 353
 SELECT object_name as table_name, owner as table_schema FROM all_objects
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleTableInfo.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -53,6 +53,8 @@
 block discarded – undo
53 53
 	/**
54 54
 	 * @param string information array key name
55 55
 	 * @param mixed default value if information array value is null
56
+	 * @param string $name
57
+	 * @param boolean $default
56 58
 	 * @return mixed information array value.
57 59
 	 */
58 60
 	public function getInfo($name,$default=null)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * Sets the database table meta data information.
33 33
 	 * @param array table column information.
34 34
 	 */
35
-	public function __construct($tableInfo=array(),$primary=array(),$foreign=array())
35
+	public function __construct($tableInfo=array(), $primary=array(), $foreign=array())
36 36
 	{
37 37
 		$this->_info=$tableInfo;
38 38
 		$this->_primaryKeys=$primary;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	public function createCommandBuilder($connection)
48 48
 	{
49 49
 		Prado::using('System.Data.Common.Oracle.TOracleCommandBuilder');
50
-		return new TOracleCommandBuilder($connection,$this);
50
+		return new TOracleCommandBuilder($connection, $this);
51 51
 	}
52 52
 
53 53
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param mixed default value if information array value is null
56 56
 	 * @return mixed information array value.
57 57
 	 */
58
-	public function getInfo($name,$default=null)
58
+	public function getInfo($name, $default=null)
59 59
 	{
60 60
 		return isset($this->_info[$name]) ? $this->_info[$name] : $default;
61 61
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @param string information array key name
65 65
 	 * @param mixed new information array value.
66 66
 	 */
67
-	protected function setInfo($name,$value)
67
+	protected function setInfo($name, $value)
68 68
 	{
69 69
 		$this->_info[$name]=$value;
70 70
 	}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function getIsView()
92 92
 	{
93
-		return $this->getInfo('IsView',false);
93
+		return $this->getInfo('IsView', false);
94 94
 	}
95 95
 
96 96
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getColumn($name)
109 109
 	{
110
-		if(($column = $this->_columns->itemAt($name))!==null)
110
+		if(($column=$this->_columns->itemAt($name))!==null)
111 111
 			return $column;
112 112
 		throw new TDbException('dbtableinfo_invalid_column_name', $name, $this->getTableFullName());
113 113
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	public function getColumnNames()
120 120
 	{
121 121
 		foreach($this->getColumns() as $column)
122
-			$names[] = $column->getColumnName();
122
+			$names[]=$column->getColumnName();
123 123
 		return $names;
124 124
 	}
125 125
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		{
149 149
 			$this->_lowercase=array();
150 150
 			foreach($this->getColumns()->getKeys() as $key)
151
-				$this->_lowercase[strtolower($key)] = $key;
151
+				$this->_lowercase[strtolower($key)]=$key;
152 152
 		}
153 153
 		return $this->_lowercase;
154 154
 	}
Please login to merge, or discard this patch.
framework/Data/Common/Pgsql/TPgsqlMetaData.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -204,6 +204,7 @@
 block discarded – undo
204 204
 	/**
205 205
 	 * @param TPgsqlTableInfo table information.
206 206
 	 * @param array column information.
207
+	 * @param TPgsqlTableInfo $tableInfo
207 208
 	 */
208 209
 	protected function processColumn($tableInfo, $col)
209 210
 	{
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -417,12 +417,12 @@
 block discarded – undo
417 417
 		return false;
418 418
 	}
419 419
 
420
-        /**
421
-	 * Returns all table names in the database.
422
-	 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
423
-	 * If not empty, the returned table names will be prefixed with the schema name.
424
-	 * @return array all table names in the database.
425
-	 */
420
+		/**
421
+		 * Returns all table names in the database.
422
+		 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
423
+		 * If not empty, the returned table names will be prefixed with the schema name.
424
+		 * @return array all table names in the database.
425
+		 */
426 426
 	public function findTableNames($schema='public')
427 427
 	{
428 428
 		if($schema==='')
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class TPgsqlMetaData extends TDbMetaData
26 26
 {
27
-	private $_defaultSchema = 'public';
27
+	private $_defaultSchema='public';
28 28
 
29 29
 	/**
30 30
 	 * @return string TDbTableInfo class name.
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	protected function getSchemaTableName($table)
88 88
 	{
89
-		if(count($parts= explode('.', str_replace('"','',$table))) > 1)
89
+		if(count($parts=explode('.', str_replace('"', '', $table))) > 1)
90 90
 			return array($parts[0], $parts[1]);
91 91
 		else
92
-			return array($this->getDefaultSchema(),$parts[0]);
92
+			return array($this->getDefaultSchema(), $parts[0]);
93 93
 	}
94 94
 
95 95
 	/**
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	protected function createTableInfo($table)
101 101
 	{
102
-		list($schemaName,$tableName) = $this->getSchemaTableName($table);
102
+		list($schemaName, $tableName)=$this->getSchemaTableName($table);
103 103
 
104 104
 		// This query is made much more complex by the addition of the 'attisserial' field.
105 105
 		// The subquery to get that field checks to see if there is an internally dependent
106 106
 		// sequence on the field.
107
-		$sql =
107
+		$sql=
108 108
 <<<EOD
109 109
 		SELECT
110 110
 			a.attname,
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 		ORDER BY a.attnum
136 136
 EOD;
137 137
 		$this->getDbConnection()->setActive(true);
138
-		$command = $this->getDbConnection()->createCommand($sql);
138
+		$command=$this->getDbConnection()->createCommand($sql);
139 139
 		$command->bindValue(':table', $tableName);
140 140
 		$command->bindValue(':schema', $schemaName);
141
-		$tableInfo = $this->createNewTableInfo($schemaName, $tableName);
141
+		$tableInfo=$this->createNewTableInfo($schemaName, $tableName);
142 142
 		$index=0;
143 143
 		foreach($command->query() as $col)
144 144
 		{
145
-			$col['index'] = $index++;
145
+			$col['index']=$index++;
146 146
 			$this->processColumn($tableInfo, $col);
147 147
 		}
148 148
 		if($index===0)
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 	 * @param string table name.
156 156
 	 * @return TPgsqlTableInfo
157 157
 	 */
158
-	protected function createNewTableInfo($schemaName,$tableName)
158
+	protected function createNewTableInfo($schemaName, $tableName)
159 159
 	{
160
-		$info['SchemaName'] = $this->assertIdentifier($schemaName);
161
-		$info['TableName'] = $this->assertIdentifier($tableName);
162
-		if($this->getIsView($schemaName,$tableName))
163
-			$info['IsView'] = true;
164
-		list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName);
165
-		$class = $this->getTableInfoClass();
166
-		return new $class($info,$primary,$foreign);
160
+		$info['SchemaName']=$this->assertIdentifier($schemaName);
161
+		$info['TableName']=$this->assertIdentifier($tableName);
162
+		if($this->getIsView($schemaName, $tableName))
163
+			$info['IsView']=true;
164
+		list($primary, $foreign)=$this->getConstraintKeys($schemaName, $tableName);
165
+		$class=$this->getTableInfoClass();
166
+		return new $class($info, $primary, $foreign);
167 167
 	}
168 168
 
169 169
 	/**
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	{
176 176
 		if(strpos($name, '"')!==false)
177 177
 		{
178
-			$ref = 'http://www.postgresql.org/docs/7.4/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS';
178
+			$ref='http://www.postgresql.org/docs/7.4/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS';
179 179
 			throw new TDbException('dbcommon_invalid_identifier_name', $name, $ref);
180 180
 		}
181 181
 		return $name;
@@ -186,19 +186,19 @@  discard block
 block discarded – undo
186 186
 	 * @param string table name.
187 187
 	 * @return boolean true if the table is a view.
188 188
 	 */
189
-	protected function getIsView($schemaName,$tableName)
189
+	protected function getIsView($schemaName, $tableName)
190 190
 	{
191
-		$sql =
191
+		$sql=
192 192
 <<<EOD
193 193
 		SELECT count(c.relname) FROM pg_catalog.pg_class c
194 194
 		LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
195 195
 		WHERE (n.nspname=:schema) AND (c.relkind = 'v'::"char") AND c.relname = :table
196 196
 EOD;
197 197
 		$this->getDbConnection()->setActive(true);
198
-		$command = $this->getDbConnection()->createCommand($sql);
199
-		$command->bindValue(':schema',$schemaName);
198
+		$command=$this->getDbConnection()->createCommand($sql);
199
+		$command->bindValue(':schema', $schemaName);
200 200
 		$command->bindValue(':table', $tableName);
201
-		return intval($command->queryScalar()) === 1;
201
+		return intval($command->queryScalar())===1;
202 202
 	}
203 203
 
204 204
 	/**
@@ -207,56 +207,56 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function processColumn($tableInfo, $col)
209 209
 	{
210
-		$columnId = $col['attname']; //use column name as column Id
210
+		$columnId=$col['attname']; //use column name as column Id
211 211
 
212
-		$info['ColumnName'] = '"'.$columnId.'"'; //quote the column names!
213
-		$info['ColumnId'] = $columnId;
214
-		$info['ColumnIndex'] = $col['index'];
212
+		$info['ColumnName']='"'.$columnId.'"'; //quote the column names!
213
+		$info['ColumnId']=$columnId;
214
+		$info['ColumnIndex']=$col['index'];
215 215
 		if(!$col['attnotnull'])
216
-			$info['AllowNull'] = true;
216
+			$info['AllowNull']=true;
217 217
 		if(in_array($columnId, $tableInfo->getPrimaryKeys()))
218
-			$info['IsPrimaryKey'] = true;
218
+			$info['IsPrimaryKey']=true;
219 219
 		if($this->isForeignKeyColumn($columnId, $tableInfo))
220
-			$info['IsForeignKey'] = true;
220
+			$info['IsForeignKey']=true;
221 221
 
222 222
 		if($col['atttypmod'] > 0)
223
-			$info['ColumnSize'] =  $col['atttypmod'] - 4;
223
+			$info['ColumnSize']=$col['atttypmod'] - 4;
224 224
 		if($col['atthasdef'])
225
-			$info['DefaultValue'] = $col['adsrc'];
226
-		if($col['attisserial'] || substr($col['adsrc'],0,8) === 'nextval(')
225
+			$info['DefaultValue']=$col['adsrc'];
226
+		if($col['attisserial'] || substr($col['adsrc'], 0, 8)==='nextval(')
227 227
 		{
228
-			if(($sequence = $this->getSequenceName($tableInfo, $col['adsrc']))!==null)
228
+			if(($sequence=$this->getSequenceName($tableInfo, $col['adsrc']))!==null)
229 229
 			{
230
-				$info['SequenceName'] = $sequence;
230
+				$info['SequenceName']=$sequence;
231 231
 				unset($info['DefaultValue']);
232 232
 			}
233 233
 		}
234
-		$matches = array();
234
+		$matches=array();
235 235
 		if(preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches))
236 236
 		{
237
-			$info['DbType'] = preg_replace('/\(\d+(?:,\d+)?\)/','',$col['type']);
237
+			$info['DbType']=preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']);
238 238
 			if($this->isPrecisionType($info['DbType']))
239 239
 			{
240
-				$info['NumericPrecision'] = intval($matches[1]);
240
+				$info['NumericPrecision']=intval($matches[1]);
241 241
 				if(count($matches) > 2)
242
-					$info['NumericScale'] = intval($matches[2]);
242
+					$info['NumericScale']=intval($matches[2]);
243 243
 			}
244 244
 			else
245
-				$info['ColumnSize'] = intval($matches[1]);
245
+				$info['ColumnSize']=intval($matches[1]);
246 246
 		}
247 247
 		else
248
-			$info['DbType'] = $col['type'];
248
+			$info['DbType']=$col['type'];
249 249
 
250
-		$tableInfo->Columns[$columnId] = new TPgsqlTableColumn($info);
250
+		$tableInfo->Columns[$columnId]=new TPgsqlTableColumn($info);
251 251
 	}
252 252
 
253 253
 	/**
254 254
 	 * @return string serial name if found, null otherwise.
255 255
 	 */
256
-	protected function getSequenceName($tableInfo,$src)
256
+	protected function getSequenceName($tableInfo, $src)
257 257
 	{
258
-		$matches = array();
259
-		if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i',$src,$matches))
258
+		$matches=array();
259
+		if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches))
260 260
 		{
261 261
 			if(is_int(strpos($matches[1], '.')))
262 262
 				return $matches[1];
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 */
271 271
 	protected function isPrecisionType($type)
272 272
 	{
273
-		$type = strtolower(trim($type));
273
+		$type=strtolower(trim($type));
274 274
 		return $type==='numeric' || $type==='interval' || strpos($type, 'time')===0;
275 275
 	}
276 276
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	protected function getConstraintKeys($schemaName, $tableName)
284 284
 	{
285
-		$sql =
285
+		$sql=
286 286
 <<<EOD
287 287
 	SELECT conname, consrc, contype, indkey, indisclustered FROM (
288 288
 			SELECT
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 			1
331 331
 EOD;
332 332
 		$this->getDbConnection()->setActive(true);
333
-		$command = $this->getDbConnection()->createCommand($sql);
333
+		$command=$this->getDbConnection()->createCommand($sql);
334 334
 		$command->bindValue(':table', $tableName);
335 335
 		$command->bindValue(':schema', $schemaName);
336
-		$primary = array();
337
-		$foreign = array();
336
+		$primary=array();
337
+		$foreign=array();
338 338
 		foreach($command->query() as $row)
339 339
 		{
340 340
 			switch($row['contype'])
341 341
 			{
342 342
 				case 'p':
343
-					$primary = $this->getPrimaryKeys($tableName, $schemaName, $row['indkey']);
343
+					$primary=$this->getPrimaryKeys($tableName, $schemaName, $row['indkey']);
344 344
 					break;
345 345
 				case 'f':
346
-					if(($fkey = $this->getForeignKeys($row['consrc']))!==null)
347
-						$foreign[] = $fkey;
346
+					if(($fkey=$this->getForeignKeys($row['consrc']))!==null)
347
+						$foreign[]=$fkey;
348 348
 					break;
349 349
 			}
350 350
 		}
351
-		return array($primary,$foreign);
351
+		return array($primary, $foreign);
352 352
 	}
353 353
 
354 354
 	/**
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 */
359 359
 	protected function getPrimaryKeys($tableName, $schemaName, $columnIndex)
360 360
 	{
361
-		$index = join(', ', explode(' ', $columnIndex));
362
-		$sql =
361
+		$index=join(', ', explode(' ', $columnIndex));
362
+		$sql=
363 363
 <<<EOD
364 364
 		SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE
365 365
 		attrelid=(
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
 		)
370 370
 				AND attnum IN ({$index})
371 371
 EOD;
372
-		$command = $this->getDbConnection()->createCommand($sql);
372
+		$command=$this->getDbConnection()->createCommand($sql);
373 373
 		$command->bindValue(':table', $tableName);
374 374
 		$command->bindValue(':schema', $schemaName);
375 375
 //		$command->bindValue(':columnIndex', join(', ', explode(' ', $columnIndex)));
376
-		$primary = array();
376
+		$primary=array();
377 377
 		foreach($command->query() as $row)
378 378
 		{
379
-						$primary[] = $row['attname'];
379
+						$primary[]=$row['attname'];
380 380
 		}
381 381
 
382 382
 		return $primary;
@@ -389,16 +389,16 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	protected function getForeignKeys($src)
391 391
 	{
392
-		$matches = array();
393
-		$brackets = '\(([^\)]+)\)';
394
-		$find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
392
+		$matches=array();
393
+		$brackets='\(([^\)]+)\)';
394
+		$find="/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
395 395
 		if(preg_match($find, $src, $matches))
396 396
 		{
397
-			$keys = preg_split('/,\s+/', $matches[1]);
398
-			$fkeys = array();
397
+			$keys=preg_split('/,\s+/', $matches[1]);
398
+			$fkeys=array();
399 399
 			foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey)
400
-				$fkeys[$keys[$i]] = $fkey;
401
-			return array('table' => str_replace('"','',$matches[2]), 'keys' => $fkeys);
400
+				$fkeys[$keys[$i]]=$fkey;
401
+			return array('table' => str_replace('"', '', $matches[2]), 'keys' => $fkeys);
402 402
 		}
403 403
 	}
404 404
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 WHERE table_schema=:schema AND table_type='BASE TABLE'
433 433
 EOD;
434 434
 		$command=$this->getDbConnection()->createCommand($sql);
435
-		$command->bindParam(':schema',$schema);
435
+		$command->bindParam(':schema', $schema);
436 436
 		$rows=$command->queryAll();
437 437
 		$names=array();
438 438
 		foreach($rows as $row)
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -233,8 +233,7 @@  discard block
 block discarded – undo
233 233
 				$newid=substr($id,$pos+1);
234 234
 				if ($control!==null)
235 235
 					$control=$control->$newid;
236
-			}
237
-			else
236
+			} else
238 237
 			{
239 238
 				// TCheckBoxList overrides findControl() with a fake implementation
240 239
 				// but accepts a second parameter to use the standard one
@@ -296,8 +295,7 @@  discard block
 block discarded – undo
296 295
 		{
297 296
 			$group=$this->getValidationGroup();
298 297
 			return $this->getPage()->getValidators($group)->getCount()>0;
299
-		}
300
-		else
298
+		} else
301 299
 			return false;
302 300
 	}
303 301
 
Please login to merge, or discard this patch.
framework/Data/Common/Sqlite/TSqliteMetaData.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -159,6 +159,7 @@
 block discarded – undo
159 159
 	 *
160 160
 	 *
161 161
 	 * @param string quoted table name.
162
+	 * @param string $table
162 163
 	 * @return array foreign key details.
163 164
 	 */
164 165
 	protected function getForeignKeys($table)
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -189,11 +189,11 @@
 block discarded – undo
189 189
 		return false;
190 190
 	}
191 191
 
192
-        /**
193
-	 * Returns all table names in the database.
194
-	 * @param string $schema the schema of the tables. This is not used for sqlite database.
195
-	 * @return array all table names in the database.
196
-	 */
192
+		/**
193
+		 * Returns all table names in the database.
194
+		 * @param string $schema the schema of the tables. This is not used for sqlite database.
195
+		 * @return array all table names in the database.
196
+		 */
197 197
 	public function findTableNames($schema='')
198 198
 	{
199 199
 		$sql="SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'";
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -69,30 +69,30 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	protected function createTableInfo($tableName)
71 71
 	{
72
-		$tableName = str_replace("'",'',$tableName);
72
+		$tableName=str_replace("'", '', $tableName);
73 73
 		$this->getDbConnection()->setActive(true);
74
-		$table = $this->getDbConnection()->quoteString($tableName);
75
-		$sql = "PRAGMA table_info({$table})";
76
-		$command = $this->getDbConnection()->createCommand($sql);
77
-		$foreign = $this->getForeignKeys($table);
74
+		$table=$this->getDbConnection()->quoteString($tableName);
75
+		$sql="PRAGMA table_info({$table})";
76
+		$command=$this->getDbConnection()->createCommand($sql);
77
+		$foreign=$this->getForeignKeys($table);
78 78
 		$index=0;
79 79
 		$columns=array();
80 80
 		$primary=array();
81 81
 		foreach($command->query() as $col)
82 82
 		{
83
-			$col['index'] = $index++;
84
-			$column = $this->processColumn($col, $foreign);
85
-			$columns[$col['name']] = $column;
83
+			$col['index']=$index++;
84
+			$column=$this->processColumn($col, $foreign);
85
+			$columns[$col['name']]=$column;
86 86
 			if($column->getIsPrimaryKey())
87
-				$primary[] = $col['name'];
87
+				$primary[]=$col['name'];
88 88
 		}
89
-		$info['TableName'] = $tableName;
89
+		$info['TableName']=$tableName;
90 90
 		if($this->getIsView($tableName))
91
-			$info['IsView'] = true;
91
+			$info['IsView']=true;
92 92
 		if(count($columns)===0)
93 93
 			throw new TDbException('dbmetadata_invalid_table_view', $tableName);
94
-		$class = $this->getTableInfoClass();
95
-		$tableInfo = new $class($info,$primary,$foreign);
94
+		$class=$this->getTableInfoClass();
95
+		$tableInfo=new $class($info, $primary, $foreign);
96 96
 		$tableInfo->getColumns()->copyFrom($columns);
97 97
 		return $tableInfo;
98 98
 	}
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	protected function getIsView($tableName)
105 105
 	{
106
-		$sql = 'SELECT count(*) FROM sqlite_master WHERE type="view" AND name= :table';
106
+		$sql='SELECT count(*) FROM sqlite_master WHERE type="view" AND name= :table';
107 107
 		$this->getDbConnection()->setActive(true);
108
-		$command = $this->getDbConnection()->createCommand($sql);
108
+		$command=$this->getDbConnection()->createCommand($sql);
109 109
 		$command->bindValue(':table', $tableName);
110
-		return intval($command->queryScalar()) === 1;
110
+		return intval($command->queryScalar())===1;
111 111
 	}
112 112
 
113 113
 	/**
@@ -117,39 +117,39 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function processColumn($col, $foreign)
119 119
 	{
120
-		$columnId = $col['name']; //use column name as column Id
120
+		$columnId=$col['name']; //use column name as column Id
121 121
 
122
-		$info['ColumnName'] = '"'.$columnId.'"'; //quote the column names!
123
-		$info['ColumnId'] = $columnId;
124
-		$info['ColumnIndex'] = $col['index'];
122
+		$info['ColumnName']='"'.$columnId.'"'; //quote the column names!
123
+		$info['ColumnId']=$columnId;
124
+		$info['ColumnIndex']=$col['index'];
125 125
 
126 126
 		if($col['notnull']!=='99')
127
-			$info['AllowNull'] = true;
127
+			$info['AllowNull']=true;
128 128
 
129 129
 		if($col['pk']==='1')
130
-			$info['IsPrimaryKey'] = true;
130
+			$info['IsPrimaryKey']=true;
131 131
 		if($this->isForeignKeyColumn($columnId, $foreign))
132
-			$info['IsForeignKey'] = true;
132
+			$info['IsForeignKey']=true;
133 133
 
134 134
 		if($col['dflt_value']!==null)
135
-			$info['DefaultValue'] = $col['dflt_value'];
135
+			$info['DefaultValue']=$col['dflt_value'];
136 136
 
137
-		$type = strtolower($col['type']);
138
-		$info['AutoIncrement'] = $type==='integer' && $col['pk']==='1';
137
+		$type=strtolower($col['type']);
138
+		$info['AutoIncrement']=$type==='integer' && $col['pk']==='1';
139 139
 
140
-		$info['DbType'] = $type;
140
+		$info['DbType']=$type;
141 141
 		$match=array();
142 142
 		if(is_int($pos=strpos($type, '(')) && preg_match('/\((.*)\)/', $type, $match))
143 143
 		{
144
-			$ps = explode(',', $match[1]);
144
+			$ps=explode(',', $match[1]);
145 145
 			if(count($ps)===2)
146 146
 			{
147
-				$info['NumericPrecision'] = intval($ps[0]);
148
-				$info['NumericScale'] = intval($ps[1]);
147
+				$info['NumericPrecision']=intval($ps[0]);
148
+				$info['NumericScale']=intval($ps[1]);
149 149
 			}
150 150
 			else
151 151
 				$info['ColumnSize']=intval($match[1]);
152
-			$info['DbType'] = substr($type,0,$pos);
152
+			$info['DbType']=substr($type, 0, $pos);
153 153
 		}
154 154
 
155 155
 		return new TSqliteTableColumn($info);
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	protected function getForeignKeys($table)
165 165
 	{
166
-		$sql = "PRAGMA foreign_key_list({$table})";
167
-		$command = $this->getDbConnection()->createCommand($sql);
168
-		$fkeys = array();
166
+		$sql="PRAGMA foreign_key_list({$table})";
167
+		$command=$this->getDbConnection()->createCommand($sql);
168
+		$fkeys=array();
169 169
 		foreach($command->query() as $col)
170 170
 		{
171
-			$fkeys[$col['table']]['keys'][$col['from']] = $col['to'];
172
-			$fkeys[$col['table']]['table'] = $col['table'];
171
+			$fkeys[$col['table']]['keys'][$col['from']]=$col['to'];
172
+			$fkeys[$col['table']]['table']=$col['table'];
173 173
 		}
174 174
 		return count($fkeys) > 0 ? array_values($fkeys) : $fkeys;
175 175
 	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -158,8 +158,7 @@
 block discarded – undo
158 158
 				$e->setAttribute('maxOccurs','unbounded');
159 159
 				$sequence->appendChild($e);
160 160
 				$complexType->appendChild($sequence);
161
-			}
162
-			else
161
+			} else
163 162
 			{
164 163
 				$all = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all');
165 164
 				foreach($elements as $elem)
Please login to merge, or discard this patch.
framework/Data/Common/TDbCommandBuilder.php 3 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	/**
68 68
 	 * Iterate through all the columns and returns the last insert id of the
69 69
 	 * first column that has a sequence or serial.
70
-	 * @return mixed last insert id, null if none is found.
70
+	 * @return string|null last insert id, null if none is found.
71 71
 	 */
72 72
 	public function getLastInsertID()
73 73
 	{
@@ -187,7 +187,6 @@  discard block
 block discarded – undo
187 187
 	 * array('col1' => 'NULL', '*')
188 188
 	 * // SELECT `col1`, `col2`, `col3`, NULL AS `col1` FROM...
189 189
 	 * </code>
190
-	 * @param mixed $value
191 190
 	 * @return array of generated fields - use implode(', ', $selectfieldlist) to collapse field list for usage
192 191
 	 * @since 3.1.7
193 192
 	 * @todo add support for table aliasing
@@ -395,7 +394,7 @@  discard block
 block discarded – undo
395 394
 	/**
396 395
 	 * Returns a list of insert field name and a list of binding names.
397 396
 	 * @param object array or object to be inserted.
398
-	 * @return array tuple ($fields, $bindings)
397
+	 * @return string[] tuple ($fields, $bindings)
399 398
 	 */
400 399
 	protected function getInsertFieldBindings($values)
401 400
 	{
@@ -439,6 +438,7 @@  discard block
 block discarded – undo
439 438
 	 * Bind the name-value pairs of $values where the array keys correspond to column names.
440 439
 	 * @param TDbCommand database command.
441 440
 	 * @param array name-value pairs.
441
+	 * @param TDbCommand $command
442 442
 	 */
443 443
 	public function bindColumnValues($command, $values)
444 444
 	{
@@ -455,6 +455,7 @@  discard block
 block discarded – undo
455 455
 	/**
456 456
 	 * @param TDbCommand database command
457 457
 	 * @param array values for binding.
458
+	 * @param TDbCommand $command
458 459
 	 */
459 460
 	public function bindArrayValues($command, $values)
460 461
 	{
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function applyLimitOffset($sql, $limit=-1, $offset=-1)
90 90
 	{
91
-		$limit = $limit!==null ? (int)$limit : -1;
92
-		$offset = $offset!==null ? (int)$offset : -1;
93
-		$limitStr = $limit >= 0 ? ' LIMIT '.$limit : '';
94
-		$offsetStr = $offset >= 0 ? ' OFFSET '.$offset : '';
91
+		$limit=$limit!==null ? (int) $limit : -1;
92
+		$offset=$offset!==null ? (int) $offset : -1;
93
+		$limitStr=$limit >= 0 ? ' LIMIT '.$limit : '';
94
+		$offsetStr=$offset >= 0 ? ' OFFSET '.$offset : '';
95 95
 		return $sql.$limitStr.$offsetStr;
96 96
 	}
97 97
 
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
 		$orders=array();
106 106
 		foreach($ordering as $name => $direction)
107 107
 		{
108
-			$direction = strtolower($direction) == 'desc' ? 'DESC' : 'ASC';
109
-			if(false !== strpos($name, '(') && false !== strpos($name, ')')) {
108
+			$direction=strtolower($direction)=='desc' ? 'DESC' : 'ASC';
109
+			if(false!==strpos($name, '(') && false!==strpos($name, ')')) {
110 110
 				// key is a function (bad practice, but we need to handle it)
111
-				$key = $name;
111
+				$key=$name;
112 112
 			} else {
113 113
 				// key is a column
114
-				$key = $this->getTableInfo()->getColumn($name)->getColumnName();
114
+				$key=$this->getTableInfo()->getColumn($name)->getColumnName();
115 115
 			}
116
-			$orders[] = $key.' '.$direction;
116
+			$orders[]=$key.' '.$direction;
117 117
 		}
118 118
 		if(count($orders) > 0)
119
-			$sql .= ' ORDER BY '.implode(', ', $orders);
119
+			$sql.=' ORDER BY '.implode(', ', $orders);
120 120
 		return $sql;
121 121
 	}
122 122
 
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function getSearchExpression($fields, $keywords)
132 132
 	{
133
-		if(strlen(trim($keywords)) == 0) return '';
134
-		$words = preg_split('/\s/u', $keywords);
135
-		$conditions = array();
133
+		if(strlen(trim($keywords))==0) return '';
134
+		$words=preg_split('/\s/u', $keywords);
135
+		$conditions=array();
136 136
 		foreach($fields as $field)
137 137
 		{
138
-			$column = $this->getTableInfo()->getColumn($field)->getColumnName();
139
-			$conditions[] = $this->getSearchCondition($column, $words);
138
+			$column=$this->getTableInfo()->getColumn($field)->getColumnName();
139
+			$conditions[]=$this->getSearchCondition($column, $words);
140 140
 		}
141 141
 		return '('.implode(' OR ', $conditions).')';
142 142
 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	{
151 151
 		$conditions=array();
152 152
 		foreach($words as $word)
153
-			$conditions[] = $column.' LIKE '.$this->getDbConnection()->quoteString('%'.$word.'%');
153
+			$conditions[]=$column.' LIKE '.$this->getDbConnection()->quoteString('%'.$word.'%');
154 154
 		return '('.implode(' AND ', $conditions).')';
155 155
 	}
156 156
 
@@ -195,102 +195,102 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	public function getSelectFieldList($data='*') {
197 197
 		if(is_scalar($data)) {
198
-			$tmp = explode(',', $data);
199
-			$result = array();
198
+			$tmp=explode(',', $data);
199
+			$result=array();
200 200
 			foreach($tmp as $v)
201
-				$result[] = trim($v);
201
+				$result[]=trim($v);
202 202
 			return $result;
203 203
 		}
204 204
 
205
-		$bHasWildcard = false;
206
-		$result = array();
205
+		$bHasWildcard=false;
206
+		$result=array();
207 207
 		if(is_array($data) || $data instanceof Traversable) {
208
-			$columns = $this->getTableInfo()->getColumns();
208
+			$columns=$this->getTableInfo()->getColumns();
209 209
 			foreach($data as $key=>$value) {
210 210
 				if($key==='*' || $value==='*') {
211
-					$bHasWildcard = true;
211
+					$bHasWildcard=true;
212 212
 					continue;
213 213
 				}
214 214
 
215 215
 				if(strToUpper($key)==='NULL') {
216
-					$result[] = 'NULL';
216
+					$result[]='NULL';
217 217
 					continue;
218 218
 				}
219 219
 
220 220
 				if(strpos($key, '(')!==false && strpos($key, ')')!==false) {
221
-					$result[] = $key;
221
+					$result[]=$key;
222 222
 					continue;
223 223
 				}
224 224
 
225 225
 				if(stripos($key, 'AS')!==false) {
226
-					$result[] = $key;
226
+					$result[]=$key;
227 227
 					continue;
228 228
 				}
229 229
 
230 230
 				if(stripos($value, 'AS')!==false) {
231
-					$result[] = $value;
231
+					$result[]=$value;
232 232
 					continue;
233 233
 				}
234 234
 
235
-				$v = isset($columns[$value]);
236
-				$k = isset($columns[$key]);
235
+				$v=isset($columns[$value]);
236
+				$k=isset($columns[$key]);
237 237
 				if(is_integer($key) && $v) {
238
-					$key = $value;
239
-					$k = $v;
238
+					$key=$value;
239
+					$k=$v;
240 240
 				}
241 241
 
242 242
 				if(strToUpper($value)==='NULL') {
243 243
 					if($k)
244
-						$result[] = 'NULL AS ' . $columns[$key]->getColumnName();
244
+						$result[]='NULL AS '.$columns[$key]->getColumnName();
245 245
 					else
246
-						$result[] = 'NULL' . (is_string($key) ? (' AS ' . (string)$key) : '');
246
+						$result[]='NULL'.(is_string($key) ? (' AS '.(string) $key) : '');
247 247
 					continue;
248 248
 				}
249 249
 
250 250
 				if(strpos($value, '(')!==false && strpos($value, ')')!==false) {
251 251
 					if($k)
252
-						$result[] = $value . ' AS ' . $columns[$key]->getColumnName();
252
+						$result[]=$value.' AS '.$columns[$key]->getColumnName();
253 253
 					else
254
-						$result[] = $value . (is_string($key) ? (' AS ' . (string)$key) : '');
254
+						$result[]=$value.(is_string($key) ? (' AS '.(string) $key) : '');
255 255
 					continue;
256 256
 				}
257 257
 
258 258
 				if($v && $key==$value) {
259
-					$result[] = $columns[$value]->getColumnName();
259
+					$result[]=$columns[$value]->getColumnName();
260 260
 					continue;
261 261
 				}
262 262
 
263 263
 				if($k && $value==null) {
264
-					$result[] = $columns[$key]->getColumnName();
264
+					$result[]=$columns[$key]->getColumnName();
265 265
 					continue;
266 266
 				}
267 267
 
268 268
 				if(is_string($key) && $v) {
269
-					$result[] = $columns[$value]->getColumnName() . ' AS ' . $key;
269
+					$result[]=$columns[$value]->getColumnName().' AS '.$key;
270 270
 					continue;
271 271
 				}
272 272
 
273 273
 				if(is_numeric($value) && $k) {
274
-					$result[] = $value . ' AS ' . $columns[$key]->getColumnName();
274
+					$result[]=$value.' AS '.$columns[$key]->getColumnName();
275 275
 					continue;
276 276
 				}
277 277
 
278 278
 				if(is_string($value) && $k) {
279
-					$result[] = $this->getDbConnection()->quoteString($value) . ' AS ' . $columns[$key]->getColumnName();
279
+					$result[]=$this->getDbConnection()->quoteString($value).' AS '.$columns[$key]->getColumnName();
280 280
 					continue;
281 281
 				}
282 282
 
283 283
 				if(!$v && !$k && is_integer($key)) {
284
-					$result[] = is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string)$value);
284
+					$result[]=is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string) $value);
285 285
 					continue;
286 286
 				}
287 287
 
288
-				$result[] = (is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string)$value)) . ' AS ' . $key;
288
+				$result[]=(is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string) $value)).' AS '.$key;
289 289
 			}
290 290
 		}
291 291
 
292
-		if($data===null || count($result) == 0 || $bHasWildcard)
293
-			$result = $result = array_merge($this->getTableInfo()->getColumnNames(), $result);
292
+		if($data===null || count($result)==0 || $bHasWildcard)
293
+			$result=$result=array_merge($this->getTableInfo()->getColumnNames(), $result);
294 294
 
295 295
 		return $result;
296 296
 	}
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	public function createFindCommand($where='1=1', $parameters=array(), $ordering=array(), $limit=-1, $offset=-1, $select='*')
306 306
 	{
307
-		$table = $this->getTableInfo()->getTableFullName();
308
-		$fields = implode(', ', $this -> getSelectFieldList($select));
309
-		$sql = "SELECT {$fields} FROM {$table}";
307
+		$table=$this->getTableInfo()->getTableFullName();
308
+		$fields=implode(', ', $this -> getSelectFieldList($select));
309
+		$sql="SELECT {$fields} FROM {$table}";
310 310
 		if(!empty($where))
311
-			$sql .= " WHERE {$where}";
311
+			$sql.=" WHERE {$where}";
312 312
 		return $this->applyCriterias($sql, $parameters, $ordering, $limit, $offset);
313 313
 	}
314 314
 
315
-	public function applyCriterias($sql, $parameters=array(),$ordering=array(), $limit=-1, $offset=-1)
315
+	public function applyCriterias($sql, $parameters=array(), $ordering=array(), $limit=-1, $offset=-1)
316 316
 	{
317 317
 		if(count($ordering) > 0)
318
-			$sql = $this->applyOrdering($sql, $ordering);
319
-		if($limit>=0 || $offset>=0)
320
-			$sql = $this->applyLimitOffset($sql, $limit, $offset);
321
-		$command = $this->createCommand($sql);
318
+			$sql=$this->applyOrdering($sql, $ordering);
319
+		if($limit >= 0 || $offset >= 0)
320
+			$sql=$this->applyLimitOffset($sql, $limit, $offset);
321
+		$command=$this->createCommand($sql);
322 322
 		$this->bindArrayValues($command, $parameters);
323 323
 		return $command;
324 324
 	}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	 * @param array binding parameters.
330 330
 	 * @return TDbCommand count command.
331 331
 	 */
332
-	public function createCountCommand($where='1=1', $parameters=array(),$ordering=array(), $limit=-1, $offset=-1)
332
+	public function createCountCommand($where='1=1', $parameters=array(), $ordering=array(), $limit=-1, $offset=-1)
333 333
 	{
334 334
 		return $this->createFindCommand($where, $parameters, $ordering, $limit, $offset, 'COUNT(*)');
335 335
 	}
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
 	 * @param array delete parameters.
343 343
 	 * @return TDbCommand delete command.
344 344
 	 */
345
-	public function createDeleteCommand($where,$parameters=array())
345
+	public function createDeleteCommand($where, $parameters=array())
346 346
 	{
347
-		$table = $this->getTableInfo()->getTableFullName();
348
-		if (!empty($where))
349
-			$where = ' WHERE '.$where;
350
-		$command = $this->createCommand("DELETE FROM {$table}".$where);
347
+		$table=$this->getTableInfo()->getTableFullName();
348
+		if(!empty($where))
349
+			$where=' WHERE '.$where;
350
+		$command=$this->createCommand("DELETE FROM {$table}".$where);
351 351
 		$this->bindArrayValues($command, $parameters);
352 352
 		return $command;
353 353
 	}
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	 */
363 363
 	public function createInsertCommand($data)
364 364
 	{
365
-		$table = $this->getTableInfo()->getTableFullName();
366
-		list($fields, $bindings) = $this->getInsertFieldBindings($data);
367
-		$command = $this->createCommand("INSERT INTO {$table}({$fields}) VALUES ($bindings)");
365
+		$table=$this->getTableInfo()->getTableFullName();
366
+		list($fields, $bindings)=$this->getInsertFieldBindings($data);
367
+		$command=$this->createCommand("INSERT INTO {$table}({$fields}) VALUES ($bindings)");
368 368
 		$this->bindColumnValues($command, $data);
369 369
 		return $command;
370 370
 	}
@@ -379,15 +379,15 @@  discard block
 block discarded – undo
379 379
 	 */
380 380
 	public function createUpdateCommand($data, $where, $parameters=array())
381 381
 	{
382
-		$table = $this->getTableInfo()->getTableFullName();
382
+		$table=$this->getTableInfo()->getTableFullName();
383 383
 		if($this->hasIntegerKey($parameters))
384
-			$fields = implode(', ', $this->getColumnBindings($data, true));
384
+			$fields=implode(', ', $this->getColumnBindings($data, true));
385 385
 		else
386
-			$fields = implode(', ', $this->getColumnBindings($data));
386
+			$fields=implode(', ', $this->getColumnBindings($data));
387 387
 
388
-		if (!empty($where))
389
-			$where = ' WHERE '.$where;
390
-		$command = $this->createCommand("UPDATE {$table} SET {$fields}".$where);
388
+		if(!empty($where))
389
+			$where=' WHERE '.$where;
390
+		$command=$this->createCommand("UPDATE {$table} SET {$fields}".$where);
391 391
 		$this->bindArrayValues($command, array_merge($data, $parameters));
392 392
 		return $command;
393 393
 	}
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 	 */
400 400
 	protected function getInsertFieldBindings($values)
401 401
 	{
402
-		$fields = array(); $bindings=array();
402
+		$fields=array(); $bindings=array();
403 403
 		foreach(array_keys($values) as $name)
404 404
 		{
405
-			$fields[] = $this->getTableInfo()->getColumn($name)->getColumnName();
406
-			$bindings[] = ':'.$name;
405
+			$fields[]=$this->getTableInfo()->getColumn($name)->getColumnName();
406
+			$bindings[]=':'.$name;
407 407
 		}
408
-		return array(implode(', ',$fields), implode(', ', $bindings));
408
+		return array(implode(', ', $fields), implode(', ', $bindings));
409 409
 	}
410 410
 
411 411
 	/**
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 		$bindings=array();
420 420
 		foreach(array_keys($values) as $name)
421 421
 		{
422
-			$column = $this->getTableInfo()->getColumn($name)->getColumnName();
423
-			$bindings[] = $position ? $column.' = ?' : $column.' = :'.$name;
422
+			$column=$this->getTableInfo()->getColumn($name)->getColumnName();
423
+			$bindings[]=$position ? $column.' = ?' : $column.' = :'.$name;
424 424
 		}
425 425
 		return $bindings;
426 426
 	}
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	{
445 445
 		foreach($values as $name=>$value)
446 446
 		{
447
-			$column = $this->getTableInfo()->getColumn($name);
448
-			if($value === null && $column->getAllowNull())
447
+			$column=$this->getTableInfo()->getColumn($name);
448
+			if($value===null && $column->getAllowNull())
449 449
 				$command->bindValue(':'.$name, null, PDO::PARAM_NULL);
450 450
 			else
451 451
 				$command->bindValue(':'.$name, $value, $column->getPdoType());
@@ -460,15 +460,15 @@  discard block
 block discarded – undo
460 460
 	{
461 461
 		if($this->hasIntegerKey($values))
462 462
 		{
463
-			$values = array_values($values);
464
-			for($i = 0, $max=count($values); $i<$max; $i++)
465
-				$command->bindValue($i+1, $values[$i], $this->getPdoType($values[$i]));
463
+			$values=array_values($values);
464
+			for($i=0, $max=count($values); $i < $max; $i++)
465
+				$command->bindValue($i + 1, $values[$i], $this->getPdoType($values[$i]));
466 466
 		}
467 467
 		else
468 468
 		{
469 469
 			foreach($values as $name=>$value)
470 470
 			{
471
-				$prop = $name[0]===':' ? $name : ':'.$name;
471
+				$prop=$name[0]===':' ? $name : ':'.$name;
472 472
 				$command->bindValue($prop, $value, $this->getPdoType($value));
473 473
 			}
474 474
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@
 block discarded – undo
58 58
 		if ($this->sourcepath === NULL)
59 59
 		{
60 60
 			$this->sourcepath = $sourcepath;
61
-		}
62
-		else
61
+		} else
63 62
 		{
64 63
 			$this->sourcepath->append($sourcepath);
65 64
 		}
Please login to merge, or discard this patch.
framework/Data/Common/TDbMetaData.php 3 patches
Doc Comments   -6 removed lines patch added patch discarded remove patch
@@ -127,8 +127,6 @@  discard block
 block discarded – undo
127 127
 	/**
128 128
 	 * Quotes a table name for use in a query.
129 129
 	 * @param string $name table name
130
-	 * @param string $lft left delimiter
131
-	 * @param string $rgt right delimiter
132 130
 	 * @return string the properly quoted table name
133 131
 	 */
134 132
 	public function quoteTableName($name)
@@ -150,8 +148,6 @@  discard block
 block discarded – undo
150 148
 	/**
151 149
 	 * Quotes a column name for use in a query.
152 150
 	 * @param string $name column name
153
-	 * @param string $lft left delimiter
154
-	 * @param string $rgt right delimiter
155 151
 	 * @return string the properly quoted column name
156 152
 	 */
157 153
 	public function quoteColumnName($name)
@@ -166,8 +162,6 @@  discard block
 block discarded – undo
166 162
 	/**
167 163
 	 * Quotes a column alias for use in a query.
168 164
 	 * @param string $name column alias
169
-	 * @param string $lft left delimiter
170
-	 * @param string $rgt right delimiter
171 165
 	 * @return string the properly quoted column alias
172 166
 	 */
173 167
 	public function quoteColumnAlias($name)
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -179,14 +179,14 @@
 block discarded – undo
179 179
 		return $lft . str_replace(self::$delimiterIdentifier, '', $name) . $rgt;
180 180
 	}
181 181
 
182
-        /**
183
-	 * Returns all table names in the database.
184
-	 * This method should be overridden by child classes in order to support this feature
185
-	 * because the default implementation simply throws an exception.
186
-	 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
187
-	 * If not empty, the returned table names will be prefixed with the schema name.
188
-	 * @return array all table names in the database.
189
-	 */
182
+		/**
183
+		 * Returns all table names in the database.
184
+		 * This method should be overridden by child classes in order to support this feature
185
+		 * because the default implementation simply throws an exception.
186
+		 * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
187
+		 * If not empty, the returned table names will be prefixed with the schema name.
188
+		 * @return array all table names in the database.
189
+		 */
190 190
 	abstract public function findTableNames($schema='');
191 191
 }
192 192
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @var array
29 29
 	 */
30
-	protected static $delimiterIdentifier = array('[', ']', '"', '`', "'");
30
+	protected static $delimiterIdentifier=array('[', ']', '"', '`', "'");
31 31
 
32 32
 	/**
33 33
 	 * @param TDbConnection database connection.
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	public static function getInstance($conn)
54 54
 	{
55 55
 		$conn->setActive(true); //must be connected before retrieving driver name
56
-		$driver = $conn->getDriverName();
56
+		$driver=$conn->getDriverName();
57 57
 		switch(strtolower($driver))
58 58
 		{
59 59
 			case 'pgsql':
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 //				Prado::using('System.Data.Common.IbmDb2.TIbmDb2MetaData');
80 80
 //				return new TIbmDb2MetaData($conn);
81 81
 			default:
82
-				throw new TDbException('ar_invalid_database_driver',$driver);
82
+				throw new TDbException('ar_invalid_database_driver', $driver);
83 83
 		}
84 84
 	}
85 85
 
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function getTableInfo($tableName=null)
92 92
 	{
93
-		$key = $tableName===null?$this->getDbConnection()->getConnectionString():$tableName;
93
+		$key=$tableName===null ? $this->getDbConnection()->getConnectionString() : $tableName;
94 94
 		if(!isset($this->_tableInfoCache[$key]))
95 95
 		{
96
-			$class = $this->getTableInfoClass();
97
-			$tableInfo = $tableName===null ? new $class : $this->createTableInfo($tableName);
98
-			$this->_tableInfoCache[$key] = $tableInfo;
96
+			$class=$this->getTableInfoClass();
97
+			$tableInfo=$tableName===null ? new $class : $this->createTableInfo($tableName);
98
+			$this->_tableInfoCache[$key]=$tableInfo;
99 99
 		}
100 100
 		return $this->_tableInfoCache[$key];
101 101
 	}
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function quoteTableName($name)
135 135
 	{
136
-		$name = str_replace(self::$delimiterIdentifier, '', $name);
136
+		$name=str_replace(self::$delimiterIdentifier, '', $name);
137 137
 
138
-		$args = func_get_args();
139
-		$rgt = $lft = isset($args[1]) ? $args[1] : '';
140
-		$rgt = isset($args[2]) ? $args[2] : $rgt;
138
+		$args=func_get_args();
139
+		$rgt=$lft=isset($args[1]) ? $args[1] : '';
140
+		$rgt=isset($args[2]) ? $args[2] : $rgt;
141 141
 
142 142
 		if(strpos($name, '.')===false)
143
-			return $lft . $name . $rgt;
143
+			return $lft.$name.$rgt;
144 144
 		$names=explode('.', $name);
145 145
 		foreach($names as &$n)
146
-			$n = $lft . $n . $rgt;
146
+			$n=$lft.$n.$rgt;
147 147
 		return implode('.', $names);
148 148
 	}
149 149
 
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function quoteColumnName($name)
158 158
 	{
159
-		$args = func_get_args();
160
-		$rgt = $lft = isset($args[1]) ? $args[1] : '';
161
-		$rgt = isset($args[2]) ? $args[2] : $rgt;
159
+		$args=func_get_args();
160
+		$rgt=$lft=isset($args[1]) ? $args[1] : '';
161
+		$rgt=isset($args[2]) ? $args[2] : $rgt;
162 162
 
163
-		return $lft . str_replace(self::$delimiterIdentifier, '', $name) . $rgt;
163
+		return $lft.str_replace(self::$delimiterIdentifier, '', $name).$rgt;
164 164
 	}
165 165
 
166 166
 	/**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public function quoteColumnAlias($name)
174 174
 	{
175
-		$args = func_get_args();
176
-		$rgt = $lft = isset($args[1]) ? $args[1] : '';
177
-		$rgt = isset($args[2]) ? $args[2] : $rgt;
175
+		$args=func_get_args();
176
+		$rgt=$lft=isset($args[1]) ? $args[1] : '';
177
+		$rgt=isset($args[2]) ? $args[2] : $rgt;
178 178
 
179
-		return $lft . str_replace(self::$delimiterIdentifier, '', $name) . $rgt;
179
+		return $lft.str_replace(self::$delimiterIdentifier, '', $name).$rgt;
180 180
 	}
181 181
 
182 182
         /**
Please login to merge, or discard this patch.