@@ -168,7 +168,7 @@ |
||
168 | 168 | * @param string $sql The SQL statement to prepare |
169 | 169 | * @param array $values a multidimensional array with the values, each row represents one line to insert. |
170 | 170 | * |
171 | - * @return bool true query success, otherwise false |
|
171 | + * @return boolean|null true query success, otherwise false |
|
172 | 172 | */ |
173 | 173 | public function multi($sql, array $values){ |
174 | 174 | // TODO: Implement multi() method. |
@@ -12,11 +12,11 @@ |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Database\Drivers\SQLite; |
14 | 14 | |
15 | +use Exception; |
|
16 | +use SQLite3; |
|
15 | 17 | use chillerlan\Database\DBException; |
16 | 18 | use chillerlan\Database\Drivers\DBBaseDriver; |
17 | 19 | use chillerlan\Database\Drivers\DBDriverInterface; |
18 | -use Exception; |
|
19 | -use SQLite3; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * |
@@ -86,6 +86,7 @@ |
||
86 | 86 | * |
87 | 87 | * @param array $stats |
88 | 88 | * @internal |
89 | + * @return void |
|
89 | 90 | */ |
90 | 91 | public function addStats(array $stats); |
91 | 92 |
@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Database\Drivers\MySQLi; |
14 | 14 | |
15 | +use ReflectionClass; |
|
15 | 16 | use chillerlan\Database\DBException; |
16 | 17 | use chillerlan\Database\Drivers\DBBaseDriver; |
17 | 18 | use chillerlan\Database\Drivers\DBDriverInterface; |
18 | 19 | use mysqli; |
19 | 20 | use mysqli_sql_exception; |
20 | -use ReflectionClass; |
|
21 | 21 | use stdClass; |
22 | 22 | |
23 | 23 | /** |
@@ -181,7 +181,7 @@ |
||
181 | 181 | if(!is_bool($result)){ |
182 | 182 | $out = []; |
183 | 183 | $method = 'fetch_'.($assoc ? ($fetch_array ? 'assoc' : 'object') : 'row'); |
184 | - $i = 0 ; |
|
184 | + $i = 0; |
|
185 | 185 | |
186 | 186 | // ok, we have a result with one or more rows, loop out the rows and output as array |
187 | 187 | while($row = $result->{$method}()){ |
@@ -11,12 +11,12 @@ |
||
11 | 11 | |
12 | 12 | namespace chillerlan\Database\Drivers\PDO; |
13 | 13 | |
14 | -use chillerlan\Database\DBException; |
|
15 | -use chillerlan\Database\Drivers\DBBaseDriver; |
|
16 | -use chillerlan\Database\Drivers\DBDriverInterface; |
|
17 | 14 | use PDO; |
18 | 15 | use PDOException; |
19 | 16 | use PDOStatement; |
17 | +use chillerlan\Database\DBException; |
|
18 | +use chillerlan\Database\Drivers\DBBaseDriver; |
|
19 | +use chillerlan\Database\Drivers\DBDriverInterface; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Class PDODriver |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | * @return array |
193 | 193 | * @internal |
194 | 194 | */ |
195 | - protected function getResult(PDOStatement &$stmt, $index, $assoc, $fetch_array){ |
|
195 | + protected function getResult(PDOStatement&$stmt, $index, $assoc, $fetch_array){ |
|
196 | 196 | $out = []; |
197 | 197 | $method = $assoc ? ($fetch_array ? PDO::FETCH_ASSOC : PDO::FETCH_OBJ) : PDO::FETCH_NUM; |
198 | - $i = 0 ; |
|
198 | + $i = 0; |
|
199 | 199 | |
200 | 200 | // ok, we have a result with one or more rows, loop out the rows and output as array |
201 | 201 | while($row = $stmt->fetch($method)){ |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | * @param array $values |
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); |
@@ -168,7 +168,7 @@ |
||
168 | 168 | * @param string $sql The SQL statement to prepare |
169 | 169 | * @param array $values a multidimensional array with the values, each row represents one line to insert. |
170 | 170 | * |
171 | - * @return bool true query success, otherwise false |
|
171 | + * @return boolean|null true query success, otherwise false |
|
172 | 172 | */ |
173 | 173 | public function multi($sql, array $values){ |
174 | 174 | // TODO: Implement multi() method. |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @param string $class FQCN |
27 | 27 | * @param string $interface FQCN |
28 | 28 | * |
29 | - * @param mixed $params [optional] the following arguments are optional and will be passed to the class constructor if present. |
|
29 | + * @param \chillerlan\Database\DBOptions $params [optional] the following arguments are optional and will be passed to the class constructor if present. |
|
30 | 30 | * |
31 | 31 | * @return object of type $interface |
32 | 32 | * @throws \chillerlan\Database\DBException |
@@ -12,8 +12,8 @@ |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Database\Traits; |
14 | 14 | |
15 | -use chillerlan\Database\DBException; |
|
16 | 15 | use ReflectionClass; |
16 | +use chillerlan\Database\DBException; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * A simple class loader |
@@ -36,7 +36,7 @@ |
||
36 | 36 | if(class_exists($class)){ |
37 | 37 | $reflectionClass = new ReflectionClass($class); |
38 | 38 | |
39 | - if(!$reflectionClass->implementsInterface($interface)) { |
|
39 | + if(!$reflectionClass->implementsInterface($interface)){ |
|
40 | 40 | throw new DBException($class.' does not implement '.$interface); |
41 | 41 | } |
42 | 42 |
@@ -31,12 +31,13 @@ |
||
31 | 31 | * @return object of type $interface |
32 | 32 | * @throws \chillerlan\Database\DBException |
33 | 33 | */ |
34 | - protected function __loadClass($class, $interface, ...$params){ // phpDocumentor stumbles across the ... syntax |
|
34 | + protected function __loadClass($class, $interface, ...$params){ |
|
35 | +// phpDocumentor stumbles across the ... syntax |
|
35 | 36 | |
36 | 37 | if(class_exists($class)){ |
37 | 38 | $reflectionClass = new ReflectionClass($class); |
38 | 39 | |
39 | - if(!$reflectionClass->implementsInterface($interface)) { |
|
40 | + if(!$reflectionClass->implementsInterface($interface)){ |
|
40 | 41 | throw new DBException($class.' does not implement '.$interface); |
41 | 42 | } |
42 | 43 |
@@ -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 | * |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @filesource PDOSQLiteDriver.php |
|
4 | - * @created 05.01.2016 |
|
5 | - * @package chillerlan\Database\Drivers\PDO |
|
6 | - * @author Smiley <[email protected]> |
|
7 | - * @copyright 2016 Smiley |
|
8 | - * @license MIT |
|
9 | - */ |
|
3 | + * @filesource PDOSQLiteDriver.php |
|
4 | + * @created 05.01.2016 |
|
5 | + * @package chillerlan\Database\Drivers\PDO |
|
6 | + * @author Smiley <[email protected]> |
|
7 | + * @copyright 2016 Smiley |
|
8 | + * @license MIT |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace chillerlan\Database\Drivers\PDO; |
12 | 12 |