@@ -2,9 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Opeyemiabiodun\PotatoORM\Connections; |
| 4 | 4 | |
| 5 | +use Opeyemiabiodun\PotatoORM\Connections\Connection; |
|
| 5 | 6 | use PDO; |
| 6 | 7 | use PDOException; |
| 7 | -use Opeyemiabiodun\PotatoORM\Connections\Connection; |
|
| 8 | 8 | |
| 9 | 9 | final class PgSqlConnection extends Connection |
| 10 | 10 | { |
@@ -12,11 +12,11 @@ |
||
| 12 | 12 | { |
| 13 | 13 | $this->useDbEnv(); |
| 14 | 14 | |
| 15 | - $dsn = 'pgsql:host='.$this->_host |
|
| 16 | - .';port='.$this->_port |
|
| 17 | - .';dbname='.$this->_database |
|
| 18 | - .';user='.$this->_username |
|
| 19 | - .';password='.$this->_password; |
|
| 15 | + $dsn = 'pgsql:host=' . $this->_host |
|
| 16 | + .';port=' . $this->_port |
|
| 17 | + .';dbname=' . $this->_database |
|
| 18 | + .';user=' . $this->_username |
|
| 19 | + .';password=' . $this->_password; |
|
| 20 | 20 | |
| 21 | 21 | try { |
| 22 | 22 | $this->_pdo = new PDO($dsn); |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | { |
| 13 | 13 | $this->useDbEnv(); |
| 14 | 14 | |
| 15 | - $dsn = 'mysql:host='.$this->_host |
|
| 16 | - .';port='.$this->_port |
|
| 17 | - .';dbname='.$this->_database; |
|
| 15 | + $dsn = 'mysql:host=' . $this->_host |
|
| 16 | + .';port=' . $this->_port |
|
| 17 | + .';dbname=' . $this->_database; |
|
| 18 | 18 | |
| 19 | 19 | try { |
| 20 | 20 | $this->_pdo = new PDO($dsn, $this->_username, $this->_password); |
@@ -2,9 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Opeyemiabiodun\PotatoORM\Connections; |
| 4 | 4 | |
| 5 | +use Opeyemiabiodun\PotatoORM\Connections\Connection; |
|
| 5 | 6 | use PDO; |
| 6 | 7 | use PDOException; |
| 7 | -use Opeyemiabiodun\PotatoORM\Connections\Connection; |
|
| 8 | 8 | |
| 9 | 9 | final class PgSqlConnection extends Connection |
| 10 | 10 | { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | protected function loadDbEnv() |
| 36 | 36 | { |
| 37 | - $dotenv = new Dotenv(__DIR__.'/..'); |
|
| 37 | + $dotenv = new Dotenv(__DIR__ . '/..'); |
|
| 38 | 38 | $dotenv->required(['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD'])->notEmpty(); |
| 39 | 39 | $dotenv->required(['DB_PORT']); |
| 40 | 40 | $dotenv->load(); |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | $sql = "INSERT INTO {$table} ("; |
| 63 | 63 | foreach ($record as $key => $value) { |
| 64 | 64 | if ($count > 1) { |
| 65 | - $sql = $sql."{$key}, "; |
|
| 65 | + $sql = $sql . "{$key}, "; |
|
| 66 | 66 | } else { |
| 67 | - $sql = $sql."{$key}) "; |
|
| 67 | + $sql = $sql . "{$key}) "; |
|
| 68 | 68 | } |
| 69 | 69 | $count--; |
| 70 | 70 | } |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | $sql .= "VALUES ("; |
| 75 | 75 | foreach ($record as $key => $value) { |
| 76 | 76 | if ($count > 1) { |
| 77 | - $sql = $sql."{$value}, "; |
|
| 77 | + $sql = $sql . "{$value}, "; |
|
| 78 | 78 | } else { |
| 79 | - $sql = $sql."{$value}) "; |
|
| 79 | + $sql = $sql . "{$value}) "; |
|
| 80 | 80 | } |
| 81 | 81 | $count--; |
| 82 | 82 | } |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | $sql = "UPDATE {$table} SET "; |
| 113 | 113 | foreach ($record as $key => $value) { |
| 114 | 114 | if ($count > 1) { |
| 115 | - $sql = $sql."{$key}={$value}, "; |
|
| 115 | + $sql = $sql . "{$key}={$value}, "; |
|
| 116 | 116 | } else { |
| 117 | - $sql = $sql."{$key}={$value} "; |
|
| 117 | + $sql = $sql . "{$key}={$value} "; |
|
| 118 | 118 | } |
| 119 | 119 | $count--; |
| 120 | 120 | } |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | { |
| 10 | 10 | protected $_attributes = []; |
| 11 | 11 | |
| 12 | - protected $_connection; |
|
| 12 | + protected $_connection; |
|
| 13 | 13 | |
| 14 | 14 | protected $_primaryKey; |
| 15 | 15 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $hasAttributes = false; |
| 56 | 56 | |
| 57 | 57 | foreach ($this->_attributes as $key => $value) { |
| 58 | - if (! is_null($value)) { |
|
| 58 | + if (!is_null($value)) { |
|
| 59 | 59 | $hasAttributes = true; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | throw new Exception("Error Processing Request", 1); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if (! $this->hasAttributes()) { |
|
| 76 | + if (!$this->hasAttributes()) { |
|
| 77 | 77 | throw new Exception("Error Processing Request", 1); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->_table = $table; |
| 91 | 91 | |
| 92 | 92 | $columns = $this->_connection->getColumns($table); |
| 93 | - for ($i=0; $i < count($columns); $i++) { |
|
| 93 | + for ($i = 0; $i < count($columns); $i++) { |
|
| 94 | 94 | array_push($this->_attributes, $columns[i][key($columns[i])]); |
| 95 | 95 | } |
| 96 | 96 | |