@@ -30,11 +30,11 @@ |
||
| 30 | 30 | * @return Select|null |
| 31 | 31 | */ |
| 32 | 32 | public function get($tableName) { |
| 33 | - if($this->has($tableName)) { |
|
| 33 | + if ($this->has($tableName)) { |
|
| 34 | 34 | $table = $this->virtualTables[(string) $tableName]; |
| 35 | - if($table instanceof \Closure) { |
|
| 35 | + if ($table instanceof \Closure) { |
|
| 36 | 36 | $params = []; |
| 37 | - if($tableName instanceof VirtualTable) { |
|
| 37 | + if ($tableName instanceof VirtualTable) { |
|
| 38 | 38 | $params = $tableName->getParams(); |
| 39 | 39 | } |
| 40 | 40 | return call_user_func($table, $params); |
@@ -13,32 +13,32 @@ |
||
| 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 $bucket) { |
|
| 27 | + foreach ($name as $bucket) { |
|
| 28 | 28 | $values = []; |
| 29 | - foreach($bucket as $field => $value) { |
|
| 29 | + foreach ($bucket as $field => $value) { |
|
| 30 | 30 | $values[] = sprintf('%s AS %s', $this->db()->quote($value), $this->db()->quoteField($field)); |
| 31 | 31 | } |
| 32 | 32 | $parts[] = sprintf("SELECT %s", join(', ', $values)); |
| 33 | 33 | } |
| 34 | - $name = '(' . join("\n\tUNION\n\t", $parts) . ')'; |
|
| 34 | + $name = '('.join("\n\tUNION\n\t", $parts).')'; |
|
| 35 | 35 | } |
| 36 | - if($this->db()->getVirtualTables()->has($name)) { |
|
| 36 | + if ($this->db()->getVirtualTables()->has($name)) { |
|
| 37 | 37 | $select = (string) $this->db()->getVirtualTables()->get($name); |
| 38 | 38 | $name = sprintf('(%s)', join("\n\t", explode("\n", trim($select)))); |
| 39 | 39 | } |
| 40 | 40 | $name = $this->aliasReplacer()->replace($name); |
| 41 | - if($alias !== null) { |
|
| 41 | + if ($alias !== null) { |
|
| 42 | 42 | return sprintf("%s %s", $name, $alias); |
| 43 | 43 | } |
| 44 | 44 | return $name; |