@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $selected = is_array($selected) ? self::identifier($selected) : $selected; |
| 37 | 37 | |
| 38 | 38 | if ($alias !== null) { |
| 39 | - $selected .= ' AS ' . self::identifier($alias); |
|
| 39 | + $selected .= ' AS '.self::identifier($alias); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return $this->addRaw($selected); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $schema = self::identifier($this->table); |
| 68 | 68 | if (!empty($this->alias)) { |
| 69 | - $schema .= ' ' . self::identifier($this->alias); |
|
| 69 | + $schema .= ' '.self::identifier($this->alias); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return sprintf('SELECT %s FROM %s', $this->deck ?? '*', $schema); |
@@ -44,10 +44,11 @@ |
||
| 44 | 44 | |
| 45 | 45 | public function addRaw(string $raw): self |
| 46 | 46 | { |
| 47 | - if (!isset($this->deck)) |
|
| 48 | - $this->deck = new Deck($raw); |
|
| 49 | - else |
|
| 50 | - $this->deck->addRaw($raw); |
|
| 47 | + if (!isset($this->deck)) { |
|
| 48 | + $this->deck = new Deck($raw); |
|
| 49 | + } else { |
|
| 50 | + $this->deck->addRaw($raw); |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | return $this; |
| 53 | 54 | } |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | public function column(string $table, string $column): array |
| 54 | 54 | { |
| 55 | 55 | if (!$this->hasColumn($table, $column)) { |
| 56 | - throw new \InvalidArgumentException('CANNOT FIND COLUMN ' . $column . ' IN TABLE ' . $table); |
|
| 56 | + throw new \InvalidArgumentException('CANNOT FIND COLUMN '.$column.' IN TABLE '.$table); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | if (!isset($this->tables[$table]['columns'][$column]['schema'])) { |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public static function cache(string $database): ?SchemaInterface |
| 23 | 23 | { |
| 24 | - $cache_file = __DIR__ . '/cache/' . $database . '.php'; |
|
| 25 | - if(!file_exists($cache_file)){ |
|
| 24 | + $cache_file = __DIR__.'/cache/'.$database.'.php'; |
|
| 25 | + if (!file_exists($cache_file)) { |
|
| 26 | 26 | return null; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -36,18 +36,18 @@ discard block |
||
| 36 | 36 | $pdo->beginTransaction(); |
| 37 | 37 | |
| 38 | 38 | // switch to the INFORMATION_SCHEMA database |
| 39 | - if(false === $pdo->query(sprintf('USE %s;', $schema_database))){ |
|
| 39 | + if (false === $pdo->query(sprintf('USE %s;', $schema_database))) { |
|
| 40 | 40 | throw new CruditesException('SWICTH_TO_INFORMATION_SCHEMA'); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // get the schema information |
| 44 | 44 | $res = $pdo->query(self::informationSchemaQuery($database)); |
| 45 | - if(false === $res){ |
|
| 45 | + if (false === $res) { |
|
| 46 | 46 | throw new CruditesException('LOAD_INFORMATION_SCHEMA'); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // switch back to the original database |
| 50 | - if(false === $pdo->query(sprintf('USE %s;', $database))){ |
|
| 50 | + if (false === $pdo->query(sprintf('USE %s;', $database))) { |
|
| 51 | 51 | throw new CruditesException('SWICTH_BACK_TO_USER_DATABASE'); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $res = $res->fetchAll(\PDO::FETCH_ASSOC); |
| 63 | - if($res === false){ |
|
| 63 | + if ($res === false) { |
|
| 64 | 64 | throw new CruditesException('SCHEMA_LOAD_FETCHALL'); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if(empty($res)){ |
|
| 67 | + if (empty($res)) { |
|
| 68 | 68 | throw new CruditesException('SCHEMA_LOAD_FETCHED_EMPTY_RESULTS'); |
| 69 | 69 | } |
| 70 | 70 | |