Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
8 / 8 |
| Hoyvoy\CrossDatabase\Query\Grammars\PostgresGrammar | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
8 / 8 |
| compileFrom | |
100.00% |
1 / 1 |
3 | |
100.00% |
8 / 8 |
|||
| <?php | |
| namespace Hoyvoy\CrossDatabase\Query\Grammars; | |
| use Illuminate\Database\Query\Builder; | |
| use Illuminate\Database\Query\Grammars\PostgresGrammar as IlluminatePostgresGrammar; | |
| class PostgresGrammar extends IlluminatePostgresGrammar | |
| { | |
| /** | |
| * Compile the "from" portion of the query. | |
| * | |
| * @param \Illuminate\Database\Query\Builder $query | |
| * @param string $table | |
| * | |
| * @return string | |
| */ | |
| protected function compileFrom(Builder $query, $table) | |
| { | |
| // Check for cross database query to attach database name | |
| if (strpos($table, '<-->') !== false) { | |
| list($prefix, $table, $database) = explode('<-->', $table); | |
| $wrappedTable = $this->wrapTable($table, true); | |
| $wrappedTablePrefixed = $this->wrap($prefix.$table, true); | |
| if ($wrappedTable != $wrappedTablePrefixed) { | |
| return 'from '.$this->wrap($database).'.'.$wrappedTablePrefixed.' as '.$wrappedTable; | |
| } | |
| return 'from '.$this->wrap($database).'.'.$wrappedTablePrefixed; | |
| } | |
| return 'from '.$this->wrapTable($table); | |
| } | |
| } |