@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | $result[] = 'NULL'; |
46 | 46 | break; |
47 | 47 | default: |
48 | - $string = (string)$fieldName; |
|
48 | + $string = (string) $fieldName; |
|
49 | 49 | if ($string == '') { |
50 | 50 | throw new ExceptionDBFieldEmpty(); |
51 | 51 | } |
52 | - $result[] = '`' . $string . '`'; |
|
52 | + $result[] = '`'.$string.'`'; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } else { |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | if (!empty($fieldList)) { |
78 | 78 | $user_record = static::$dbStatic->doquery( |
79 | 79 | ( |
80 | - "SELECT {$fieldList}" . |
|
81 | - " FROM {{" . static::$_table . "}}" . |
|
82 | - (!empty($where) ? " WHERE {$where}" : '') . |
|
83 | - (!empty($for_update) ? " FOR UPDATE" : '') . |
|
80 | + "SELECT {$fieldList}". |
|
81 | + " FROM {{".static::$_table."}}". |
|
82 | + (!empty($where) ? " WHERE {$where}" : ''). |
|
83 | + (!empty($for_update) ? " FOR UPDATE" : ''). |
|
84 | 84 | ($returnFirst ? ' LIMIT 1' : '') |
85 | 85 | ), |
86 | 86 | $returnFirst |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function getRecordById($recordId, $fieldList = '*', $forUpdate = false) { |
139 | 139 | // return static::getRecord(array(static::$_idField => $recordId), $fieldList, $forUpdate); |
140 | - return static::getRecord(array(static::$_idField . '=' . $recordId), $fieldList, $forUpdate); |
|
140 | + return static::getRecord(array(static::$_idField.'='.$recordId), $fieldList, $forUpdate); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | DbSqlStatement::build(null, get_called_class()) |
159 | 159 | ->select() |
160 | 160 | ->fields(static::$_idField) |
161 | - ->where(array("`" . static::$_idField . "` IN (" . implode(',', $idList) . ")")) |
|
161 | + ->where(array("`".static::$_idField."` IN (".implode(',', $idList).")")) |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class ExceptionDbSqlWhereNotAnArray extends Exception{ |
|
3 | +class ExceptionDbSqlWhereNotAnArray extends Exception { |
|
4 | 4 | |
5 | 5 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // TODO - fields should be escaped !! |
167 | 167 | // TODO - $where should be validated and checked! |
168 | 168 | public function where($where = array()) { |
169 | - if(!is_array($where)) { |
|
169 | + if (!is_array($where)) { |
|
170 | 170 | throw new ExceptionDbSqlWhereNotAnArray(); |
171 | 171 | } |
172 | 172 | $this->where = $where; |
@@ -198,23 +198,23 @@ discard block |
||
198 | 198 | $result = ''; |
199 | 199 | $result .= $this->stringEscape($this->operation); |
200 | 200 | |
201 | - $result .= ' ' . $this->selectFieldsToString($this->fields); |
|
201 | + $result .= ' '.$this->selectFieldsToString($this->fields); |
|
202 | 202 | |
203 | 203 | $result .= ' FROM'; |
204 | - $result .= ' `{{' . $this->stringEscape($this->table) . '}}`'; |
|
205 | - $result .= !empty($this->alias) ? ' AS `' . $this->stringEscape($this->alias) . '`' : ''; |
|
204 | + $result .= ' `{{'.$this->stringEscape($this->table).'}}`'; |
|
205 | + $result .= !empty($this->alias) ? ' AS `'.$this->stringEscape($this->alias).'`' : ''; |
|
206 | 206 | |
207 | 207 | // TODO - fields should be escaped !! |
208 | - $result .= !empty($this->where) ? ' WHERE ' . implode(' AND ', $this->where) : ''; |
|
208 | + $result .= !empty($this->where) ? ' WHERE '.implode(' AND ', $this->where) : ''; |
|
209 | 209 | |
210 | 210 | // TODO - fields should be escaped !! |
211 | - $result .= !empty($this->group) ? ' GROUP BY ' . implode(',', $this->group) : ''; |
|
211 | + $result .= !empty($this->group) ? ' GROUP BY '.implode(',', $this->group) : ''; |
|
212 | 212 | |
213 | 213 | // TODO - fields should be escaped !! |
214 | - $result .= !empty($this->order) ? ' ORDER BY ' . implode(',', $this->order) : ''; |
|
214 | + $result .= !empty($this->order) ? ' ORDER BY '.implode(',', $this->order) : ''; |
|
215 | 215 | |
216 | 216 | // TODO - fields should be escaped !! |
217 | - $result .= !empty($this->limit) ? ' LIMIT ' . implode(',', $this->limit) : ''; |
|
217 | + $result .= !empty($this->limit) ? ' LIMIT '.implode(',', $this->limit) : ''; |
|
218 | 218 | |
219 | 219 | // TODO - protect from double escape! |
220 | 220 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function processField($fieldName) { |
254 | 254 | if (is_bool($fieldName)) { |
255 | - $result = (string)intval($fieldName); |
|
255 | + $result = (string) intval($fieldName); |
|
256 | 256 | } elseif (is_null($fieldName)) { |
257 | 257 | $result = 'NULL'; |
258 | 258 | } elseif ($fieldName === '*') { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @return string |
271 | 271 | */ |
272 | 272 | protected function processFieldDefault($fieldName) { |
273 | - $result = (string)$fieldName; |
|
273 | + $result = (string) $fieldName; |
|
274 | 274 | if ( |
275 | 275 | $result != '' |
276 | 276 | && |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | !is_numeric($fieldName) |
285 | 285 | ) { |
286 | 286 | // Other should be formatted |
287 | - $result = '`' . $this->stringEscape($result) . '`'; |
|
287 | + $result = '`'.$this->stringEscape($result).'`'; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | return $result; |