@@ -9,15 +9,14 @@ |
||
9 | 9 | |
10 | 10 | namespace chillerlan\DatabaseTest; |
11 | 11 | |
12 | +use Dotenv\Dotenv; |
|
12 | 13 | use chillerlan\Database\DBOptions; |
13 | 14 | use chillerlan\Database\Drivers\MySQLi\MySQLiDriver; |
14 | -use chillerlan\Database\Drivers\PDO\PDOFirebirdDriver; |
|
15 | 15 | use chillerlan\Database\Drivers\PDO\PDOMySQLDriver; |
16 | 16 | use chillerlan\Database\Drivers\PDO\PDOPostgresDriver; |
17 | 17 | use chillerlan\Database\Drivers\PDO\PDOSQLiteDriver; |
18 | 18 | use chillerlan\Database\Drivers\PostgreSQL\PostgreSQLDriver; |
19 | 19 | use chillerlan\Database\Drivers\SQLite\SQLite3Driver; |
20 | -use Dotenv\Dotenv; |
|
21 | 20 | |
22 | 21 | class DBInstanceTest extends \PHPUnit_Framework_TestCase{ |
23 | 22 |
@@ -39,15 +39,15 @@ |
||
39 | 39 | public function driverDataProvider(){ |
40 | 40 | return [ |
41 | 41 | // native |
42 | - ['MYSQLI', MySQLiDriver::class, 'mysqli'], |
|
43 | - ['POSTGRESQL', PostgreSQLDriver::class, 'resource'], |
|
44 | - ['SQLITE3', SQLite3Driver::class, 'SQLite3'], |
|
42 | + ['MYSQLI', MySQLiDriver::class, 'mysqli'], |
|
43 | + ['POSTGRESQL', PostgreSQLDriver::class, 'resource'], |
|
44 | + ['SQLITE3', SQLite3Driver::class, 'SQLite3'], |
|
45 | 45 | |
46 | 46 | // PDO (obviously) |
47 | - ['PDO_MYSQL', PDOMySQLDriver::class, 'PDO'], |
|
47 | + ['PDO_MYSQL', PDOMySQLDriver::class, 'PDO'], |
|
48 | 48 | ['PDO_POSTGRES', PDOPostgresDriver::class, 'PDO'], |
49 | 49 | # ['PDO_FIREBIRD', PDOFirebirdDriver::class, 'PDO'], // https://github.com/asfernandes/firebird/blob/master/.travis.yml |
50 | - ['PDO_SQLITE', PDOSQLiteDriver::class, 'PDO'], |
|
50 | + ['PDO_SQLITE', PDOSQLiteDriver::class, 'PDO'], |
|
51 | 51 | ]; |
52 | 52 | } |
53 | 53 |
@@ -129,7 +129,7 @@ |
||
129 | 129 | * |
130 | 130 | * @var int |
131 | 131 | */ |
132 | - public $sqlite_flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE; |
|
132 | + public $sqlite_flags = SQLITE3_OPEN_READWRITE|SQLITE3_OPEN_CREATE; |
|
133 | 133 | /** |
134 | 134 | * An optional encryption key used when encrypting and decrypting an SQLite database. |
135 | 135 | * |
@@ -12,6 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Database\Drivers\MySQLi; |
14 | 14 | |
15 | +use ReflectionMethod; |
|
15 | 16 | use chillerlan\Database\DBException; |
16 | 17 | use chillerlan\Database\Drivers\DBBaseDriver; |
17 | 18 | use chillerlan\Database\Drivers\DBDriverInterface; |
@@ -19,8 +20,6 @@ discard block |
||
19 | 20 | use mysqli_result; |
20 | 21 | use mysqli_sql_exception; |
21 | 22 | use mysqli_stmt; |
22 | -use ReflectionClass; |
|
23 | -use ReflectionMethod; |
|
24 | 23 | use stdClass; |
25 | 24 | |
26 | 25 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | $out = []; |
188 | 188 | $method = 'fetch_'.($assoc ? ($fetch_array ? 'assoc' : 'object') : 'row'); |
189 | - $i = 0 ; |
|
189 | + $i = 0; |
|
190 | 190 | |
191 | 191 | // ok, we have a result with one or more rows, loop out the rows and output as array |
192 | 192 | while($row = $result->{$method}()){ |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return void |
354 | 354 | */ |
355 | - protected function insertPreparedRow(mysqli_stmt &$stmt, ReflectionMethod &$reflectionMethod, array &$row){ |
|
355 | + protected function insertPreparedRow(mysqli_stmt&$stmt, ReflectionMethod&$reflectionMethod, array &$row){ |
|
356 | 356 | $references = $this->getReferences($row); |
357 | 357 | array_unshift($references, $this->getTypes($references)); |
358 | 358 | $reflectionMethod->invokeArgs($stmt, $references); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return array|bool |
372 | 372 | */ |
373 | - protected function getResult(mysqli_stmt &$stmt, mysqli_result &$result, string $index, bool $assoc, bool $fetch_array){ |
|
373 | + protected function getResult(mysqli_stmt&$stmt, mysqli_result&$result, string $index, bool $assoc, bool $fetch_array){ |
|
374 | 374 | // get the columns and their references |
375 | 375 | // http://php.net/manual/mysqli-stmt.bind-result.php |
376 | 376 | $cols = $refs = []; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | foreach($values as &$v){ |
427 | 427 | switch(gettype($v)){ |
428 | 428 | case 'integer': $types[] = 'i'; break; |
429 | - case 'double': $types[] ='d'; break; |
|
429 | + case 'double': $types[] = 'd'; break; |
|
430 | 430 | default: $types[] = 's'; break; |
431 | 431 | } |
432 | 432 | } |
@@ -12,10 +12,10 @@ |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Database\Drivers\SQLite; |
14 | 14 | |
15 | -use chillerlan\Database\DBException; |
|
16 | -use chillerlan\Database\Drivers\DBDriverAbstract; |
|
17 | 15 | use Exception; |
18 | 16 | use SQLite3; |
17 | +use chillerlan\Database\DBException; |
|
18 | +use chillerlan\Database\Drivers\DBDriverAbstract; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * |
@@ -12,10 +12,10 @@ |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Database\Drivers\SQLite; |
14 | 14 | |
15 | -use chillerlan\Database\DBException; |
|
16 | -use chillerlan\Database\Drivers\DBDriverAbstract; |
|
17 | 15 | use Exception; |
18 | 16 | use SQLite3; |
17 | +use chillerlan\Database\DBException; |
|
18 | +use chillerlan\Database\Drivers\DBDriverAbstract; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | * @return array |
192 | 192 | * @internal |
193 | 193 | */ |
194 | - protected function getResult(PDOStatement &$stmt, string $index, bool $assoc, bool $fetch_array):array { |
|
194 | + protected function getResult(PDOStatement&$stmt, string $index, bool $assoc, bool $fetch_array):array { |
|
195 | 195 | $out = []; |
196 | 196 | $method = $assoc ? ($fetch_array ? PDO::FETCH_ASSOC : PDO::FETCH_OBJ) : PDO::FETCH_NUM; |
197 | - $i = 0 ; |
|
197 | + $i = 0; |
|
198 | 198 | |
199 | 199 | // ok, we have a result with one or more rows, loop out the rows and output as array |
200 | 200 | while($row = $stmt->fetch($method)){ |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | * @return void |
226 | 226 | * @internal |
227 | 227 | */ |
228 | - protected function bindParams(PDOStatement &$stmt, array $values){ |
|
228 | + protected function bindParams(PDOStatement&$stmt, array $values){ |
|
229 | 229 | $param_no = 1; |
230 | 230 | |
231 | 231 | foreach($values as $v){ |
232 | 232 | |
233 | 233 | switch(gettype($v)){ |
234 | 234 | case 'boolean': $type = PDO::PARAM_BOOL; break; |
235 | - case 'integer': $type = PDO::PARAM_INT; break; |
|
235 | + case 'integer': $type = PDO::PARAM_INT; break; |
|
236 | 236 | case 'NULL': $type = PDO::PARAM_NULL; break; |
237 | - default: $type = PDO::PARAM_STR; break; |
|
237 | + default: $type = PDO::PARAM_STR; break; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $stmt->bindValue($param_no, $v, $type); |
@@ -52,7 +52,7 @@ |
||
52 | 52 | * Firebird -> SQLSTATE[IM001]: driver does not support lastInsertId() |
53 | 53 | * |
54 | 54 | * @link http://php.net/manual/pdo.lastinsertid.php |
55 | - * @return null |
|
55 | + * @return string |
|
56 | 56 | */ |
57 | 57 | protected function insertID():string { |
58 | 58 | return null; |
@@ -58,7 +58,7 @@ |
||
58 | 58 | * |
59 | 59 | * @return array stats |
60 | 60 | */ |
61 | - public function getStats():array ; |
|
61 | + public function getStats():array; |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Enables query stat recording |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @return resource the database resource object |
33 | 33 | * @throws \chillerlan\Database\DBException |
34 | 34 | */ |
35 | - public function connect() { |
|
35 | + public function connect(){ |
|
36 | 36 | |
37 | 37 | if(gettype($this->db) === 'resource'){ |
38 | 38 | return $this->db; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @return resource the database resource object |
33 | 33 | * @throws \chillerlan\Database\DBException |
34 | 34 | */ |
35 | - public function connect() { |
|
35 | + public function connect(){ |
|
36 | 36 | |
37 | 37 | if(gettype($this->db) === 'resource'){ |
38 | 38 | return $this->db; |