@@ -21,7 +21,7 @@ |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | protected function buildOffset($query) { |
24 | - if($this->offset !== null) { |
|
24 | + if ($this->offset !== null) { |
|
25 | 25 | $query .= "OFFSET\n\t{$this->offset}\n"; |
26 | 26 | } |
27 | 27 | return $query; |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * @return $this |
14 | 14 | */ |
15 | 15 | public function groupBy() { |
16 | - foreach(func_get_args() as $expression) { |
|
17 | - if(is_array($expression)) { |
|
18 | - if(!count($expression)) { |
|
16 | + foreach (func_get_args() as $expression) { |
|
17 | + if (is_array($expression)) { |
|
18 | + if (!count($expression)) { |
|
19 | 19 | continue; |
20 | 20 | } |
21 | 21 | $arguments = array( |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | * @return string |
35 | 35 | */ |
36 | 36 | protected function buildGroups($query) { |
37 | - if(!count($this->groupBy)) { |
|
37 | + if (!count($this->groupBy)) { |
|
38 | 38 | return $query; |
39 | 39 | } |
40 | 40 | $query .= "GROUP BY\n"; |
41 | 41 | $arr = array(); |
42 | - foreach($this->groupBy as $expression) { |
|
42 | + foreach ($this->groupBy as $expression) { |
|
43 | 43 | $arr[] = "\t{$expression}"; |
44 | 44 | } |
45 | 45 | return $query.join(",\n", $arr)."\n"; |
@@ -10,17 +10,17 @@ |
||
10 | 10 | * @return string |
11 | 11 | */ |
12 | 12 | protected function buildTableName($alias, $name) { |
13 | - if(is_object($name)) { |
|
13 | + if (is_object($name)) { |
|
14 | 14 | $name = (string) $name; |
15 | 15 | $lines = explode("\n", $name); |
16 | - foreach($lines as &$line) { |
|
16 | + foreach ($lines as &$line) { |
|
17 | 17 | $line = "\t{$line}"; |
18 | 18 | } |
19 | 19 | $name = join("\n", $lines); |
20 | - $name = '(' . trim(rtrim(trim($name), ';')) . ')'; |
|
20 | + $name = '('.trim(rtrim(trim($name), ';')).')'; |
|
21 | 21 | } |
22 | 22 | $name = $this->aliasReplacer()->replace($name); |
23 | - if($alias !== null) { |
|
23 | + if ($alias !== null) { |
|
24 | 24 | return sprintf("%s %s", $name, $alias); |
25 | 25 | } |
26 | 26 | return $name; |
@@ -30,21 +30,21 @@ |
||
30 | 30 | * @return string |
31 | 31 | */ |
32 | 32 | protected function buildUnions($query) { |
33 | - $wrap = function ($query) { |
|
33 | + $wrap = function($query) { |
|
34 | 34 | $query = trim($query); |
35 | 35 | $query = join("\n\t", explode("\n", $query)); |
36 | 36 | return sprintf("(\n\t%s\n)", $query); |
37 | 37 | }; |
38 | 38 | $queries = [$wrap($query)]; |
39 | - foreach($this->unions as $unionQuery) { |
|
40 | - if($unionQuery[0] === 'ALL') { |
|
39 | + foreach ($this->unions as $unionQuery) { |
|
40 | + if ($unionQuery[0] === 'ALL') { |
|
41 | 41 | $queries[] = 'UNION ALL'; |
42 | 42 | } else { |
43 | 43 | $queries[] = 'UNION'; |
44 | 44 | } |
45 | 45 | $queries[] = $wrap($unionQuery[1]); |
46 | 46 | } |
47 | - if(count($queries) > 1) { |
|
47 | + if (count($queries) > 1) { |
|
48 | 48 | return join(" ", $queries); |
49 | 49 | } |
50 | 50 | return $query; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @return $this |
16 | 16 | */ |
17 | 17 | protected function addTable($alias, $table = null) { |
18 | - if($table === null) { |
|
18 | + if ($table === null) { |
|
19 | 19 | list($alias, $table) = [$table, $alias]; |
20 | 20 | } |
21 | 21 | $this->tables[] = array('alias' => $alias, 'name' => $table); |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | */ |
29 | 29 | protected function buildTables($query) { |
30 | 30 | $arr = array(); |
31 | - foreach($this->tables as $table) { |
|
31 | + foreach ($this->tables as $table) { |
|
32 | 32 | $arr[] = "\t".$this->buildTableName($table['alias'], $table['name']); |
33 | 33 | } |
34 | - if(count($arr)) { |
|
34 | + if (count($arr)) { |
|
35 | 35 | $query .= join(",\n", $arr)."\n"; |
36 | 36 | } |
37 | 37 | return $query; |
@@ -49,15 +49,15 @@ |
||
49 | 49 | */ |
50 | 50 | protected function buildJoins($query) { |
51 | 51 | $arr = array(); |
52 | - foreach($this->joinTables as $table) { |
|
52 | + foreach ($this->joinTables as $table) { |
|
53 | 53 | $join = $table['type']." JOIN\n"; |
54 | - $join .= "\t" . $this->buildTableName($table['alias'], $table['name']); |
|
55 | - if($table['expression']) { |
|
56 | - $join .= " ON " . $this->db()->quoteExpression($table['expression'], $table['arguments']); |
|
54 | + $join .= "\t".$this->buildTableName($table['alias'], $table['name']); |
|
55 | + if ($table['expression']) { |
|
56 | + $join .= " ON ".$this->db()->quoteExpression($table['expression'], $table['arguments']); |
|
57 | 57 | } |
58 | 58 | $arr[] = $join; |
59 | 59 | } |
60 | - if(count($arr)) { |
|
60 | + if (count($arr)) { |
|
61 | 61 | $query .= join("\n", $arr)."\n"; |
62 | 62 | } |
63 | 63 | return $query; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @return $this |
30 | 30 | */ |
31 | 31 | public function from($alias, $table = null) { |
32 | - if($table !== null) { |
|
32 | + if ($table !== null) { |
|
33 | 33 | $this->aliases[] = $alias; |
34 | 34 | } |
35 | 35 | $this->addTable($alias, $table); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public function __toString() { |
44 | 44 | $query = "DELETE "; |
45 | 45 | $query .= join(', ', $this->aliases); |
46 | - $query = trim($query) . " FROM\n"; |
|
46 | + $query = trim($query)." FROM\n"; |
|
47 | 47 | $query = $this->buildTables($query); |
48 | 48 | $query = $this->buildJoins($query); |
49 | 49 | $query = $this->buildWhereConditions($query); |
@@ -8,8 +8,8 @@ |
||
8 | 8 | * @return array |
9 | 9 | */ |
10 | 10 | public static function convertValues(array $row, array $columnDefinitions) { |
11 | - foreach($row as $key => &$value) { |
|
12 | - if($value !== null) { |
|
11 | + foreach ($row as $key => &$value) { |
|
12 | + if ($value !== null) { |
|
13 | 13 | $value = self::convertValue($value, $columnDefinitions[$key]); |
14 | 14 | } |
15 | 15 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | public function run(array $params = array()) { |
26 | 26 | $this->query->execute($params); |
27 | 27 | $response = $this->query->getStatement()->rowCount(); |
28 | - if($this->callbackFn !== null) { |
|
28 | + if ($this->callbackFn !== null) { |
|
29 | 29 | $response = call_user_func($this->callbackFn, $response); |
30 | 30 | } |
31 | 31 | return $response; |