@@ -13,36 +13,36 @@ |
||
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | 15 | protected function buildTableName($alias, $name) { |
| 16 | - if(is_object($name) && !($name instanceof VirtualTable)) { |
|
| 16 | + if (is_object($name) && !($name instanceof VirtualTable)) { |
|
| 17 | 17 | $name = (string) $name; |
| 18 | 18 | $lines = explode("\n", $name); |
| 19 | - foreach($lines as &$line) { |
|
| 19 | + foreach ($lines as &$line) { |
|
| 20 | 20 | $line = "\t{$line}"; |
| 21 | 21 | } |
| 22 | 22 | $name = join("\n", $lines); |
| 23 | - $name = '(' . trim(rtrim(trim($name), ';')) . ')'; |
|
| 23 | + $name = '('.trim(rtrim(trim($name), ';')).')'; |
|
| 24 | 24 | } |
| 25 | - if(is_array($name)) { |
|
| 25 | + if (is_array($name)) { |
|
| 26 | 26 | $parts = []; |
| 27 | - foreach($name as $index => $bucket) { |
|
| 28 | - if(ctype_digit((string) $index) && is_scalar($bucket)) { |
|
| 27 | + foreach ($name as $index => $bucket) { |
|
| 28 | + if (ctype_digit((string) $index) && is_scalar($bucket)) { |
|
| 29 | 29 | $parts[] = "SELECT {$this->db()->quote($bucket)} AS {$this->db()->quoteField('value')}"; |
| 30 | 30 | } else { |
| 31 | 31 | $values = []; |
| 32 | - foreach($bucket as $field => $value) { |
|
| 32 | + foreach ($bucket as $field => $value) { |
|
| 33 | 33 | $values[] = sprintf('%s AS %s', $this->db()->quote($value), $this->db()->quoteField($field)); |
| 34 | 34 | } |
| 35 | 35 | $parts[] = sprintf("SELECT %s", join(', ', $values)); |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - $name = '(' . join("\n\tUNION\n\t", $parts) . ')'; |
|
| 38 | + $name = '('.join("\n\tUNION\n\t", $parts).')'; |
|
| 39 | 39 | } |
| 40 | - if($this->db()->getVirtualTables()->has($name)) { |
|
| 40 | + if ($this->db()->getVirtualTables()->has($name)) { |
|
| 41 | 41 | $select = (string) $this->db()->getVirtualTables()->get($name); |
| 42 | 42 | $name = sprintf('(%s)', join("\n\t", explode("\n", trim($select)))); |
| 43 | 43 | } |
| 44 | 44 | $name = $this->aliasReplacer()->replace($name); |
| 45 | - if($alias !== null) { |
|
| 45 | + if ($alias !== null) { |
|
| 46 | 46 | return sprintf("%s %s", $name, $alias); |
| 47 | 47 | } |
| 48 | 48 | return $name; |