Completed
Push — prado-3.3 ( f4da81...5dd4b5 )
by Fabio
09:03
created
framework/Data/Common/Pgsql/TPgsqlTableInfo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	public function createCommandBuilder($connection)
51 51
 	{
52 52
 		Prado::using('System.Data.Common.Pgsql.TPgsqlCommandBuilder');
53
-		return new TPgsqlCommandBuilder($connection,$this);
53
+		return new TPgsqlCommandBuilder($connection, $this);
54 54
 	}
55 55
 }
56 56
 
Please login to merge, or discard this patch.
framework/Data/Common/Pgsql/TPgsqlMetaData.php 1 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.
framework/Data/Common/Pgsql/TPgsqlTableColumn.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	 */
36 36
 	public function getPHPType()
37 37
 	{
38
-		$dbtype = strtolower($this->getDbType());
38
+		$dbtype=strtolower($this->getDbType());
39 39
 		foreach(self::$types as $type => $dbtypes)
40 40
 		{
41 41
 			if(in_array($dbtype, $dbtypes))
Please login to merge, or discard this patch.
framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function getSearchExpression($fields, $keywords)
32 32
 	{
33
-		$columns = array();
33
+		$columns=array();
34 34
 		foreach($fields as $field)
35 35
 		{
36 36
 			if($this->isSearchableColumn($this->getTableInfo()->getColumn($field)))
37
-				$columns[] = $field;
37
+				$columns[]=$field;
38 38
 		}
39 39
 		return parent::getSearchExpression($columns, $keywords);
40 40
 	}
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	protected function isSearchableColumn($column)
46 46
 	{
47
-		$type = strtolower($column->getDbType());
48
-		return $type === 'character varying' || $type === 'varchar' ||
49
-				$type === 'character' || $type === 'char' || $type === 'text';
47
+		$type=strtolower($column->getDbType());
48
+		return $type==='character varying' || $type==='varchar' ||
49
+				$type==='character' || $type==='char' || $type==='text';
50 50
 	}
51 51
 
52 52
 	/**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	{
60 60
 		$conditions=array();
61 61
 		foreach($words as $word)
62
-			$conditions[] = $column.' ILIKE '.$this->getDbConnection()->quoteString('%'.$word.'%');
62
+			$conditions[]=$column.' ILIKE '.$this->getDbConnection()->quoteString('%'.$word.'%');
63 63
 		return '('.implode(' AND ', $conditions).')';
64 64
 	}
65 65
 
Please login to merge, or discard this patch.
framework/Data/Common/TDbCommandBuilder.php 1 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.
framework/Data/Common/TDbTableColumn.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class TDbTableColumn extends TComponent
20 20
 {
21
-	const UNDEFINED_VALUE= INF; //use infinity for undefined value
21
+	const UNDEFINED_VALUE=INF; //use infinity for undefined value
22 22
 
23 23
 	private $_info=array();
24 24
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param mixed default value if information array value is null
37 37
 	 * @return mixed information array value.
38 38
 	 */
39
-	protected function getInfo($name,$default=null)
39
+	protected function getInfo($name, $default=null)
40 40
 	{
41 41
 		return isset($this->_info[$name]) ? $this->_info[$name] : $default;
42 42
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param string information array key name
46 46
 	 * @param mixed new information array value.
47 47
 	 */
48
-	protected function setInfo($name,$value)
48
+	protected function setInfo($name, $value)
49 49
 	{
50 50
 		$this->_info[$name]=$value;
51 51
 	}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function getAllowNull()
120 120
 	{
121
-		return $this->getInfo('AllowNull',false);
121
+		return $this->getInfo('AllowNull', false);
122 122
 	}
123 123
 
124 124
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		if(($precision=$this->getNumericPrecision())!==null)
151 151
 		{
152 152
 			$scale=$this->getNumericScale();
153
-			return $scale===null ? pow(10,$precision) : pow(10,$precision-$scale);
153
+			return $scale===null ? pow(10, $precision) : pow(10, $precision - $scale);
154 154
 		}
155 155
 	}
156 156
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function getIsPrimaryKey()
161 161
 	{
162
-		return $this->getInfo('IsPrimaryKey',false);
162
+		return $this->getInfo('IsPrimaryKey', false);
163 163
 	}
164 164
 
165 165
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function getIsForeignKey()
169 169
 	{
170
-		return $this->getInfo('IsForeignKey',false);
170
+		return $this->getInfo('IsForeignKey', false);
171 171
 	}
172 172
 
173 173
 	/**
Please login to merge, or discard this patch.
framework/Data/Common/Mssql/TMssqlCommandBuilder.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		{
32 32
 			if($column->hasSequence())
33 33
 			{
34
-				$command = $this->getDbConnection()->createCommand('SELECT @@Identity');
34
+				$command=$this->getDbConnection()->createCommand('SELECT @@Identity');
35 35
 				return intval($command->queryScalar());
36 36
 			}
37 37
 		}
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function applyLimitOffset($sql, $limit=-1, $offset=-1)
81 81
 	{
82
-		$limit = $limit!==null ? intval($limit) : -1;
83
-		$offset = $offset!==null ? intval($offset) : -1;
84
-		if ($limit > 0 && $offset <= 0) //just limit
85
-			$sql = preg_replace('/^([\s(])*SELECT( DISTINCT)?(?!\s*TOP\s*\()/i',"\\1SELECT\\2 TOP $limit", $sql);
82
+		$limit=$limit!==null ? intval($limit) : -1;
83
+		$offset=$offset!==null ? intval($offset) : -1;
84
+		if($limit > 0 && $offset <= 0) //just limit
85
+			$sql=preg_replace('/^([\s(])*SELECT( DISTINCT)?(?!\s*TOP\s*\()/i', "\\1SELECT\\2 TOP $limit", $sql);
86 86
 		else if($limit > 0 && $offset > 0)
87
-			$sql = $this->rewriteLimitOffsetSql($sql, $limit,$offset);
87
+			$sql=$this->rewriteLimitOffsetSql($sql, $limit, $offset);
88 88
 		return $sql;
89 89
 	}
90 90
 
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	protected function rewriteLimitOffsetSql($sql, $limit, $offset)
100 100
 	{
101
-		$fetch = $limit+$offset;
102
-		$sql = preg_replace('/^([\s(])*SELECT( DISTINCT)?(?!\s*TOP\s*\()/i',"\\1SELECT\\2 TOP $fetch", $sql);
103
-		$ordering = $this->findOrdering($sql);
101
+		$fetch=$limit + $offset;
102
+		$sql=preg_replace('/^([\s(])*SELECT( DISTINCT)?(?!\s*TOP\s*\()/i', "\\1SELECT\\2 TOP $fetch", $sql);
103
+		$ordering=$this->findOrdering($sql);
104 104
 
105
-		$orginalOrdering = $this->joinOrdering($ordering);
106
-		$reverseOrdering = $this->joinOrdering($this->reverseDirection($ordering));
107
-		$sql = "SELECT * FROM (SELECT TOP {$limit} * FROM ($sql) as [__inner top table__] {$reverseOrdering}) as [__outer top table__] {$orginalOrdering}";
105
+		$orginalOrdering=$this->joinOrdering($ordering);
106
+		$reverseOrdering=$this->joinOrdering($this->reverseDirection($ordering));
107
+		$sql="SELECT * FROM (SELECT TOP {$limit} * FROM ($sql) as [__inner top table__] {$reverseOrdering}) as [__outer top table__] {$orginalOrdering}";
108 108
 		return $sql;
109 109
 	}
110 110
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 		$matches=array();
122 122
 		$ordering=array();
123 123
 		preg_match_all('/(ORDER BY)[\s"\[](.*)(ASC|DESC)?(?:[\s"\[]|$|COMPUTE|FOR)/i', $sql, $matches);
124
-		if(count($matches)>1 && count($matches[2]) > 0)
124
+		if(count($matches) > 1 && count($matches[2]) > 0)
125 125
 		{
126
-			$parts = explode(',', $matches[2][0]);
126
+			$parts=explode(',', $matches[2][0]);
127 127
 			foreach($parts as $part)
128 128
 			{
129 129
 				$subs=array();
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 				{
132 132
 					if(count($subs) > 1 && count($subs[2]) > 0)
133 133
 					{
134
-						$ordering[$subs[1][0]] = $subs[2][0];
134
+						$ordering[$subs[1][0]]=$subs[2][0];
135 135
 					}
136 136
 					//else what?
137 137
 				}
138 138
 				else
139
-					$ordering[trim($part)] = 'ASC';
139
+					$ordering[trim($part)]='ASC';
140 140
 			}
141 141
 		}
142 142
 		return $ordering;
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	protected function joinOrdering($orders)
150 150
 	{
151
-		if(count($orders)>0)
151
+		if(count($orders) > 0)
152 152
 		{
153 153
 			$str=array();
154 154
 			foreach($orders as $column => $direction)
155
-				$str[] = $column.' '.$direction;
155
+				$str[]=$column.' '.$direction;
156 156
 			return 'ORDER BY '.implode(', ', $str);
157 157
 		}
158 158
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	protected function reverseDirection($orders)
165 165
 	{
166 166
 		foreach($orders as $column => $direction)
167
-			$orders[$column] = strtolower(trim($direction))==='desc' ? 'ASC' : 'DESC';
167
+			$orders[$column]=strtolower(trim($direction))==='desc' ? 'ASC' : 'DESC';
168 168
 		return $orders;
169 169
 	}
170 170
 }
Please login to merge, or discard this patch.
framework/Data/Common/Mssql/TMssqlTableInfo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 	public function createCommandBuilder($connection)
57 57
 	{
58 58
 		Prado::using('System.Data.Common.Mssql.TMssqlCommandBuilder');
59
-		return new TMssqlCommandBuilder($connection,$this);
59
+		return new TMssqlCommandBuilder($connection, $this);
60 60
 	}
61 61
 }
62 62
 
Please login to merge, or discard this patch.
framework/Data/Common/Mssql/TMssqlMetaData.php 1 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.