Completed
Push — prado4-sauce ( 31ba42...77d75b )
by Fabio
16:20 queued 08:27
created
framework/Data/Common/Oracle/TOracleCommandBuilder.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	 * @return string SQL search condition matching on a set of columns.
31 31
 	 */
32 32
 	public function getSearchExpression($fields, $keywords) {
33
-		$columns = array ();
34
-		foreach ($fields as $field) {
35
-			if ($this->isSearchableColumn($this->getTableInfo()->getColumn($field)))
36
-				$columns[] = $field;
33
+		$columns=array();
34
+		foreach($fields as $field) {
35
+			if($this->isSearchableColumn($this->getTableInfo()->getColumn($field)))
36
+				$columns[]=$field;
37 37
 		}
38 38
 		return parent :: getSearchExpression($columns, $keywords);
39 39
 	}
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @return boolean true if column can be used for LIKE searching.
43 43
 	 */
44 44
 	protected function isSearchableColumn($column) {
45
-		$type = strtolower($column->getDbType());
46
-		return $type === 'character varying' || $type === 'varchar2' || $type === 'character' || $type === 'char' || $type === 'text';
45
+		$type=strtolower($column->getDbType());
46
+		return $type==='character varying' || $type==='varchar2' || $type==='character' || $type==='char' || $type==='text';
47 47
 	}
48 48
 
49 49
 	/**
@@ -72,59 +72,59 @@  discard block
 block discarded – undo
72 72
 	 * @param integer row offset, -1 to ignore offset.
73 73
 	 * @return string SQL with limit and offset in Oracle way.
74 74
 	 */
75
-	public function applyLimitOffset($sql, $limit = -1, $offset = -1) {
76
-		if ((int) $limit <= 0 && (int) $offset <= 0)
75
+	public function applyLimitOffset($sql, $limit=-1, $offset=-1) {
76
+		if((int) $limit <= 0 && (int) $offset <= 0)
77 77
 			return $sql;
78 78
 
79
-		$pradoNUMLIN = 'pradoNUMLIN';
80
-		$fieldsALIAS = 'xyz';
79
+		$pradoNUMLIN='pradoNUMLIN';
80
+		$fieldsALIAS='xyz';
81 81
 
82
-		$nfimDaSQL = strlen($sql);
83
-		$nfimDoWhere = (strpos($sql, 'ORDER') !== false ? strpos($sql, 'ORDER') : $nfimDaSQL);
84
-		$niniDoSelect = strpos($sql, 'SELECT') + 6;
85
-		$nfimDoSelect = (strpos($sql, 'FROM') !== false ? strpos($sql, 'FROM') : $nfimDaSQL);
82
+		$nfimDaSQL=strlen($sql);
83
+		$nfimDoWhere=(strpos($sql, 'ORDER')!==false ? strpos($sql, 'ORDER') : $nfimDaSQL);
84
+		$niniDoSelect=strpos($sql, 'SELECT') + 6;
85
+		$nfimDoSelect=(strpos($sql, 'FROM')!==false ? strpos($sql, 'FROM') : $nfimDaSQL);
86 86
 
87 87
 		$WhereInSubSelect="";
88 88
 		if(strpos($sql, 'WHERE')!==false)
89
-			$WhereInSubSelect = "WHERE " .substr($sql, strpos($sql, 'WHERE')+5, $nfimDoWhere - $niniDoWhere);
89
+			$WhereInSubSelect="WHERE ".substr($sql, strpos($sql, 'WHERE') + 5, $nfimDoWhere - $niniDoWhere);
90 90
 
91
-		$sORDERBY = '';
92
-		if (stripos($sql, 'ORDER') !== false) {
93
-			$p = stripos($sql, 'ORDER');
94
-			$sORDERBY = substr($sql, $p +8);
91
+		$sORDERBY='';
92
+		if(stripos($sql, 'ORDER')!==false) {
93
+			$p=stripos($sql, 'ORDER');
94
+			$sORDERBY=substr($sql, $p + 8);
95 95
 		}
96 96
 
97
-		$fields = substr($sql, 0, $nfimDoSelect);
98
-		$fields = trim(substr($fields, $niniDoSelect));
99
-		$aliasedFields = ', ';
97
+		$fields=substr($sql, 0, $nfimDoSelect);
98
+		$fields=trim(substr($fields, $niniDoSelect));
99
+		$aliasedFields=', ';
100 100
 
101
-		if (trim($fields) == '*') {
102
-			$aliasedFields = ", {$fieldsALIAS}.{$fields}";
103
-			$fields = '';
104
-			$arr = $this->getTableInfo()->getColumns();
105
-			foreach ($arr as $field) {
106
-				$fields .= strtolower($field->getColumnName()) . ', ';
101
+		if(trim($fields)=='*') {
102
+			$aliasedFields=", {$fieldsALIAS}.{$fields}";
103
+			$fields='';
104
+			$arr=$this->getTableInfo()->getColumns();
105
+			foreach($arr as $field) {
106
+				$fields.=strtolower($field->getColumnName()).', ';
107 107
 			}
108
-			$fields = str_replace('"', '', $fields);
109
-			$fields = trim($fields);
110
-			$fields = substr($fields, 0, strlen($fields) - 1);
108
+			$fields=str_replace('"', '', $fields);
109
+			$fields=trim($fields);
110
+			$fields=substr($fields, 0, strlen($fields) - 1);
111 111
 		} else {
112
-			if (strpos($fields, ',') !== false) {
113
-				$arr = $this->getTableInfo()->getColumns();
114
-				foreach ($arr as $field) {
115
-					$field = strtolower($field);
116
-					$existAS = str_ireplace(' as ', '-as-', $field);
117
-					if (strpos($existAS, '-as-') === false)
118
-						$aliasedFields .= "{$fieldsALIAS}." . trim($field) . ", ";
112
+			if(strpos($fields, ',')!==false) {
113
+				$arr=$this->getTableInfo()->getColumns();
114
+				foreach($arr as $field) {
115
+					$field=strtolower($field);
116
+					$existAS=str_ireplace(' as ', '-as-', $field);
117
+					if(strpos($existAS, '-as-')===false)
118
+						$aliasedFields.="{$fieldsALIAS}.".trim($field).", ";
119 119
 					else
120
-						$aliasedFields .= "{$field}, ";
120
+						$aliasedFields.="{$field}, ";
121 121
 				}
122
-				$aliasedFields = trim($aliasedFields);
123
-				$aliasedFields = substr($aliasedFields, 0, strlen($aliasedFields) - 1);
122
+				$aliasedFields=trim($aliasedFields);
123
+				$aliasedFields=substr($aliasedFields, 0, strlen($aliasedFields) - 1);
124 124
 			}
125 125
 		}
126
-		if ($aliasedFields == ', ')
127
-			$aliasedFields = " , $fieldsALIAS.* ";
126
+		if($aliasedFields==', ')
127
+			$aliasedFields=" , $fieldsALIAS.* ";
128 128
 
129 129
 		/* ************************
130 130
 		$newSql = " SELECT $fields FROM ".
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 				  ") WHERE {$pradoNUMLIN} >= {$offset} ";
135 135
 
136 136
 		************************* */
137
-		$offset=(int)$offset;
138
-		$toReg = $offset + $limit ;
139
-		$fullTableName = $this->getTableInfo()->getTableFullName();
140
-		if (empty ($sORDERBY))
137
+		$offset=(int) $offset;
138
+		$toReg=$offset + $limit;
139
+		$fullTableName=$this->getTableInfo()->getTableFullName();
140
+		if(empty ($sORDERBY))
141 141
 			$sORDERBY="ROWNUM";
142 142
 
143
-		$newSql = 	" SELECT $fields FROM " .
144
-					"(					" .
145
-					"		SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} " .
146
-					"		FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect" .
147
-					") nn					" .
143
+		$newSql=" SELECT $fields FROM ".
144
+					"(					".
145
+					"		SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} ".
146
+					"		FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect".
147
+					") nn					".
148 148
 					" WHERE nn.{$pradoNUMLIN} >= {$offset} AND nn.{$pradoNUMLIN} < {$toReg} ";
149 149
 		//echo $newSql."\n<br>\n";
150 150
 		return $newSql;
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleTableColumn.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 class TOracleTableColumn extends TDbTableColumn
25 25
 {
26 26
 	private static $types=array(
27
-		'numeric' => array( 'numeric' )
27
+		'numeric' => array('numeric')
28 28
 //		'integer' => array('bit', 'bit varying', 'real', 'serial', 'int', 'integer'),
29 29
 //		'boolean' => array('boolean'),
30 30
 //		'float' => array('bigint', 'bigserial', 'double precision', 'money', 'numeric')
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function getPHPType()
38 38
 	{
39
-		$dbtype = strtolower($this->getDbType());
39
+		$dbtype=strtolower($this->getDbType());
40 40
 		foreach(self::$types as $type => $dbtypes)
41 41
 		{
42 42
 			if(in_array($dbtype, $dbtypes))
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleTableInfo.php 2 patches
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.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 	/**
49 49
 	 * @param TDbConnection database connection.
50
-	 * @return TDbCommandBuilder new command builder
50
+	 * @return TOracleCommandBuilder new command builder
51 51
 	 */
52 52
 	public function createCommandBuilder($connection)
53 53
 	{
@@ -57,6 +57,8 @@  discard block
 block discarded – undo
57 57
 	/**
58 58
 	 * @param string information array key name
59 59
 	 * @param mixed default value if information array value is null
60
+	 * @param string $name
61
+	 * @param boolean $default
60 62
 	 * @return mixed information array value.
61 63
 	 */
62 64
 	public function getInfo($name,$default=null)
Please login to merge, or discard this patch.
framework/Data/Common/Pgsql/TPgsqlTableInfo.php 2 patches
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.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 
49 49
 	/**
50 50
 	 * @param TDbConnection database connection.
51
-	 * @return TDbCommandBuilder new command builder
51
+	 * @return TPgsqlCommandBuilder new command builder
52 52
 	 */
53 53
 	public function createCommandBuilder($connection)
54 54
 	{
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 3 patches
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.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -191,7 +191,6 @@  discard block
 block discarded – undo
191 191
 	 * array('col1' => 'NULL', '*')
192 192
 	 * // SELECT `col1`, `col2`, `col3`, NULL AS `col1` FROM...
193 193
 	 * </code>
194
-	 * @param mixed $value
195 194
 	 * @return array of generated fields - use implode(', ', $selectfieldlist) to collapse field list for usage
196 195
 	 * @since 3.1.7
197 196
 	 * @todo add support for table aliasing
@@ -399,7 +398,7 @@  discard block
 block discarded – undo
399 398
 	/**
400 399
 	 * Returns a list of insert field name and a list of binding names.
401 400
 	 * @param object array or object to be inserted.
402
-	 * @return array tuple ($fields, $bindings)
401
+	 * @return string[] tuple ($fields, $bindings)
403 402
 	 */
404 403
 	protected function getInsertFieldBindings($values)
405 404
 	{
Please login to merge, or discard this patch.
framework/Data/Common/Mssql/TMssqlCommandBuilder.php 2 patches
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.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,8 +70,7 @@
 block discarded – undo
70 70
 				{
71 71
 					$domain=substr($value,$pos+1);
72 72
 					return $domain===''?false:checkdnsrr($domain,'MX');
73
-				}
74
-				else
73
+				} else
75 74
 					return false;
76 75
 			}
77 76
 		}
Please login to merge, or discard this patch.
framework/Data/Common/Mssql/TMssqlTableInfo.php 2 patches
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.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 
55 55
 	/**
56 56
 	 * @param TDbConnection database connection.
57
-	 * @return TDbCommandBuilder new command builder
57
+	 * @return TMssqlCommandBuilder new command builder
58 58
 	 */
59 59
 	public function createCommandBuilder($connection)
60 60
 	{
Please login to merge, or discard this patch.