Skip to content

Commit b592e59

Browse files
committed
1 parent 02ce252 commit b592e59

10 files changed

+40
-44
lines changed

.travis.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,19 @@ language: php
33
php:
44
- 7.2
55

6-
services:
7-
- mysql
8-
- postgresql
9-
- sqlite3
6+
matrix:
7+
include:
8+
- php: 7.2
9+
- php: nightly
10+
allow_failures:
11+
- php: nightly
1012

11-
before_install:
12-
- pip install --user codecov
13-
14-
install:
15-
- travis_retry composer install --no-interaction --prefer-source
13+
install: travis_retry composer install --no-interaction --prefer-source
1614

1715
before_script:
1816
- mysql -e 'create database dbtest;'
1917
- psql -c 'create database dbtest;' -U postgres
2018

21-
script:
22-
- vendor/bin/phpunit --configuration phpunit.xml --coverage-clover clover.xml
19+
script: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover clover.xml
2320

24-
after_success:
25-
- codecov
21+
after_success: bash <(curl -s https://codecov.io/bash)

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ A PHP 7.2+ SQL client and querybuilder for the most common databases.
4848
{
4949
"require": {
5050
"php": ">=7.2.0",
51-
"chillerlan/database": "dev-master"
51+
"chillerlan/database": "^2.1"
5252
}
5353
}
5454
```
@@ -185,7 +185,9 @@ method | return | description
185185
------ | ------ | -----------
186186
`sql()` | `string` | returns the SQL for the current statement
187187
`bindValues()` | `array` | returns the values for each '?' parameter in the SQL
188-
`execute(string $index = null, array $values = null, $callback = null)` | `Result` | Executes the current statement. `$index` is being used in "SELECT" statements to determine a column to index the `Result` by. `$values` and `$callback` can be used to provide multiple values on multi row "INSERT" or "UPDATE" queries.
188+
`query(string $index = null` | `Result` | Executes the current statement. `$index` is being used in "SELECT" statements to determine a column to index the `Result` by. `$values`.
189+
`multi(array $values = null)` | bool | Executes the current statement as multi query. `$values` needs to be a multi dimensional array with each row.
190+
`callback(array $values = null, $callback = null)` | bool | Executes the current statement. `$index` is being used in "SELECT" statements to determine a column to index the `Result` by. `$values` and `$callback` can be used to provide multiple values on multi row "INSERT" or "UPDATE" queries.
189191

190192

191193
### `Create`
@@ -208,7 +210,7 @@ $conn->create
208210
->database('test')
209211
->ifNotExists()
210212
->charset('utf8mb4_bin')
211-
->execute();
213+
->query();
212214
```
213215
```mysql
214216
CREATE DATABASE IF NOT EXISTS `test` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
@@ -240,7 +242,7 @@ $conn->create
240242
->decimal('weight', '8,3')
241243
->int('added', 10, 0, null, 'UNSIGNED')
242244
->primaryKey('id')
243-
->execute();
245+
->query();
244246
```
245247
The generated Query will look something like this
246248
```mysql
@@ -283,13 +285,13 @@ method | description
283285
$conn->insert
284286
->into('products')
285287
->values(['name' => 'product1', 'type' => 'a', 'price' => 3.99, 'weight' => 0.1, 'added' => time()])
286-
->execute();
288+
->query();
287289
```
288290
```mysql
289291
INSERT INTO `products` (`name`, `type`, `price`, `weight`, `added`) VALUES (?,?,?,?,?)
290292
```
291293

292-
An array with multiple rows will automatically perform a multi insert
294+
293295
```php
294296
$values = [
295297
['name' => 'product2', 'type' => 'b', 'price' => 4.20, 'weight' => 2.35, 'added' => time()],
@@ -298,8 +300,7 @@ $values = [
298300

299301
$conn->insert
300302
->into('products')
301-
->values($values)
302-
->execute();
303+
->multi($values);
303304
```
304305
As an alternative, you can provide the values via a callback
305306
```php
@@ -311,8 +312,8 @@ $values = [
311312

312313
$conn->insert
313314
->into('products')
314-
->values(['name' => '?', 'type' => '?', 'price' => '?', 'weight' => '?', 'added' => '?'])
315-
->execute(null, $values, function($row){
315+
->values([['name' => '?', 'type' => '?', 'price' => '?', 'weight' => '?', 'added' => '?']])
316+
->callback($values, function($row){
316317
return [
317318
$row[0],
318319
$row[1],

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
},
2323
"require": {
2424
"php": "^7.2",
25-
"chillerlan/php-traits": "^1.1",
25+
"chillerlan/php-traits": "^2.0",
2626
"psr/simple-cache": "^1.0",
2727
"psr/log": "^1.0"
2828
},
2929
"require-dev": {
30-
"chillerlan/php-cache": "^1.0",
31-
"chillerlan/php-log": "^1.0",
32-
"phpunit/phpunit": "^7.1"
30+
"chillerlan/php-cache": "^2.0",
31+
"chillerlan/php-log": "^2.0",
32+
"phpunit/phpunit": "^7.3"
3333
},
3434
"autoload": {
3535
"psr-4": {

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
1312
<filter>
1413
<whitelist processUncoveredFilesFromWhitelist="true">

src/DatabaseAbstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Drivers\DriverInterface, Query\QueryBuilder
1717
};
1818
use chillerlan\Traits\{
19-
ClassLoader, ContainerInterface
19+
ClassLoader, ImmutableSettingsInterface
2020
};
2121
use Psr\Log\{
2222
LoggerAwareInterface, LoggerAwareTrait, LoggerInterface, NullLogger
@@ -49,11 +49,11 @@ abstract class DatabaseAbstract implements LoggerAwareInterface{
4949
/**
5050
* Database constructor.
5151
*
52-
* @param \chillerlan\Traits\ContainerInterface $options
52+
* @param \chillerlan\Traits\ImmutableSettingsInterface $options
5353
* @param \Psr\SimpleCache\CacheInterface|null $cache
5454
* @param \Psr\Log\LoggerInterface|null $logger
5555
*/
56-
public function __construct(ContainerInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null){
56+
public function __construct(ImmutableSettingsInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null){
5757
$this->options = $options;
5858
$this->cache = $cache;
5959

src/DatabaseOptions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace chillerlan\Database;
1414

15-
use chillerlan\Traits\ContainerAbstract;
15+
use chillerlan\Traits\ImmutableSettingsAbstract;
1616

1717
/**
1818
* @property string $driver
@@ -41,6 +41,6 @@
4141
* @property string $cachekey_hash_algo
4242
* @property string $storage_path
4343
*/
44-
class DatabaseOptions extends ContainerAbstract{
44+
class DatabaseOptions extends ImmutableSettingsAbstract{
4545
use DatabaseOptionsTrait;
4646
}

src/Drivers/DriverAbstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use chillerlan\Database\{
1616
Dialects\Dialect, Result
1717
};
18-
use chillerlan\Traits\ContainerInterface;
18+
use chillerlan\Traits\ImmutableSettingsInterface;
1919
use Psr\Log\{
2020
LoggerAwareInterface, LoggerAwareTrait, LoggerInterface
2121
};
@@ -60,11 +60,11 @@ abstract class DriverAbstract implements DriverInterface, LoggerAwareInterface{
6060
/**
6161
* Constructor.
6262
*
63-
* @param \chillerlan\Traits\ContainerInterface $options
63+
* @param \chillerlan\Traits\ImmutableSettingsInterface $options
6464
* @param \Psr\SimpleCache\CacheInterface|null $cache
6565
* @param \Psr\Log\LoggerInterface|null $logger
6666
*/
67-
public function __construct(ContainerInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null){
67+
public function __construct(ImmutableSettingsInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null){
6868
$this->options = $options;
6969
$this->cache = $cache;
7070
$this->logger = $logger;

src/Drivers/DriverInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace chillerlan\Database\Drivers;
1414

1515
use chillerlan\Database\Dialects\Dialect;
16-
use chillerlan\Traits\ContainerInterface;
16+
use chillerlan\Traits\ImmutableSettingsInterface;
1717
use Psr\Log\LoggerInterface;
1818
use Psr\SimpleCache\CacheInterface;
1919

@@ -22,11 +22,11 @@ interface DriverInterface{
2222
/**
2323
* Constructor.
2424
*
25-
* @param \chillerlan\Traits\ContainerInterface $options
25+
* @param \chillerlan\Traits\ImmutableSettingsInterface $options
2626
* @param \Psr\SimpleCache\CacheInterface|null $cache
2727
* @param \Psr\Log\LoggerInterface|null $logger
2828
*/
29-
public function __construct(ContainerInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null);
29+
public function __construct(ImmutableSettingsInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null);
3030

3131
/**
3232
* Establishes a database connection and returns the connection object

src/Drivers/MSSqlSrvPDO.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace chillerlan\Database\Drivers;
1414

1515
use chillerlan\Database\Dialects\MSSQL;
16-
use chillerlan\Traits\ContainerInterface;
16+
use chillerlan\Traits\ImmutableSettingsInterface;
1717
use PDO;
1818
use Psr\{
1919
Log\LoggerInterface, SimpleCache\CacheInterface
@@ -30,11 +30,11 @@ class MSSqlSrvPDO extends PDODriverAbstract{
3030
/**
3131
* MSSqlSrvPDO constructor.
3232
*
33-
* @param \chillerlan\Traits\ContainerInterface $options
33+
* @param \chillerlan\Traits\ImmutableSettingsInterface $options
3434
* @param \Psr\SimpleCache\CacheInterface|null $cache
3535
* @param \Psr\Log\LoggerInterface|null $log
3636
*/
37-
public function __construct(ContainerInterface $options, CacheInterface $cache = null, LoggerInterface $log = null){
37+
public function __construct(ImmutableSettingsInterface $options, CacheInterface $cache = null, LoggerInterface $log = null){
3838
unset($this->pdo_options[PDO::ATTR_EMULATE_PREPARES]);
3939

4040
// @todo

src/Dumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace chillerlan\Database;
1414

15-
use chillerlan\Traits\ContainerInterface;
15+
use chillerlan\Traits\ImmutableSettingsInterface;
1616
use Psr\Log\LoggerInterface;
1717
use Psr\SimpleCache\CacheInterface;
1818

@@ -28,7 +28,7 @@ class Dumper extends DatabaseAbstract{
2828
*/
2929
protected $dialect;
3030

31-
public function __construct(ContainerInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null){
31+
public function __construct(ImmutableSettingsInterface $options, CacheInterface $cache = null, LoggerInterface $logger = null){
3232
parent::__construct($options, $cache, $logger);
3333

3434
$this->dialect = $this->driver->getDialect();

0 commit comments

Comments
 (0)