@@ -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,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 | * |
@@ -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 | |
@@ -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 | * |
@@ -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); |
@@ -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 | * |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * |
|
| 4 | - * @filesource ClassLoaderTraitTest.php |
|
| 5 | - * @created 29.02.2016 |
|
| 6 | - * @package chillerlan\DatabaseTest\Traits |
|
| 7 | - * @author Smiley <[email protected]> |
|
| 8 | - * @copyright 2015 Smiley |
|
| 9 | - * @license MIT |
|
| 10 | - */ |
|
| 3 | + * |
|
| 4 | + * @filesource ClassLoaderTraitTest.php |
|
| 5 | + * @created 29.02.2016 |
|
| 6 | + * @package chillerlan\DatabaseTest\Traits |
|
| 7 | + * @author Smiley <[email protected]> |
|
| 8 | + * @copyright 2015 Smiley |
|
| 9 | + * @license MIT |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | namespace chillerlan\DatabaseTest\Traits; |
| 13 | 13 | |
@@ -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 | /** |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | $out = []; |
| 189 | 189 | $method = 'fetch_'.($assoc ? ($fetch_array ? 'assoc' : 'object') : 'row'); |
| 190 | - $i = 0 ; |
|
| 190 | + $i = 0; |
|
| 191 | 191 | |
| 192 | 192 | // ok, we have a result with one or more rows, loop out the rows and output as array |
| 193 | 193 | while($row = $result->{$method}()){ |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * @param \ReflectionMethod $reflectionMethod |
| 352 | 352 | * @param array $row |
| 353 | 353 | */ |
| 354 | - protected function insertPreparedRow(mysqli_stmt &$stmt, ReflectionMethod &$reflectionMethod, array &$row){ |
|
| 354 | + protected function insertPreparedRow(mysqli_stmt&$stmt, ReflectionMethod&$reflectionMethod, array &$row){ |
|
| 355 | 355 | $references = $this->getReferences($row); |
| 356 | 356 | array_unshift($references, $this->getTypes($references)); |
| 357 | 357 | $reflectionMethod->invokeArgs($stmt, $references); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * |
| 367 | 367 | * @return array|bool |
| 368 | 368 | */ |
| 369 | - protected function getResult(mysqli_stmt &$stmt, mysqli_result &$result, $assoc, $fetch_array){ |
|
| 369 | + protected function getResult(mysqli_stmt&$stmt, mysqli_result&$result, $assoc, $fetch_array){ |
|
| 370 | 370 | // get the columns and their references |
| 371 | 371 | // http://php.net/manual/mysqli-stmt.bind-result.php |
| 372 | 372 | $cols = $refs = []; |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | foreach($values as &$v){ |
| 423 | 423 | switch(gettype($v)){ |
| 424 | 424 | case 'integer': $types[] = 'i'; break; |
| 425 | - case 'double': $types[] ='d'; break; |
|
| 425 | + case 'double': $types[] = 'd'; break; |
|
| 426 | 426 | default: $types[] = 's'; break; |
| 427 | 427 | } |
| 428 | 428 | } |