diff --git a/.travis.yml b/.travis.yml index b85230e..3d21dff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,8 @@ language: php php: - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - 7.3 + - 7.4 services: - postgresql @@ -16,7 +12,7 @@ addons: postgresql: "9.5" sudo: required -dist: precise +dist: bionic before_script: - 'composer install --dev --prefer-source' diff --git a/README.md b/README.md index 9eea88b..a5ce274 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ the internal `protected` portion of the API; typically, a major `0.x+1` release ### Contributions -Current target is php 5.5 and later, see `.travis.yml`. +Current target is php 7.0 and later, see `.travis.yml`. Code adheres to [PSR-2](http://www.php-fig.org/psr/psr-2/) and [PSR-4](http://www.php-fig.org/psr/psr-4/). diff --git a/composer.json b/composer.json index 14a637b..2b054cf 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ } }, "require": { - "php": ">=5.5", + "php": ">=7.0", "ext-pdo": "*", "mindplay/unbox": "^2", "psr/log": "^1" @@ -29,7 +29,7 @@ "require-dev": { "mindplay/testies": "^0.3.2", "mindplay/benchpress": "^0.1", - "mockery/mockery": "^0.9", + "mockery/mockery": "^1.5.0", "phpunit/php-code-coverage": ">=2, <4" }, "suggest": { diff --git a/src/framework/Result.php b/src/framework/Result.php index e5ce894..173c1f7 100644 --- a/src/framework/Result.php +++ b/src/framework/Result.php @@ -85,7 +85,7 @@ public function all() * * @return Iterator */ - public function getIterator() + public function getIterator(): Iterator { return $this->createIterator($this->batch_size); } diff --git a/src/framework/pdo/PreparedPDOStatement.php b/src/framework/pdo/PreparedPDOStatement.php index ce3f0ad..df306c7 100644 --- a/src/framework/pdo/PreparedPDOStatement.php +++ b/src/framework/pdo/PreparedPDOStatement.php @@ -8,6 +8,7 @@ use mindplay\sql\model\Driver; use mindplay\sql\model\TypeProvider; use PDO; +use PDOException; use PDOStatement; /** @@ -104,7 +105,13 @@ public function execute() { $microtime_begin = microtime(true); - if (@$this->handle->execute()) { + try { + $execution_successful = @$this->handle->execute(); + } catch (PDOException $e) { + $execution_successful = false; + } + + if ($execution_successful) { $this->executed = true; $microtime_end = microtime(true); $time_msec = ($microtime_end - $microtime_begin) * 1000; diff --git a/test/test-integration.php b/test/test-integration.php index 14c9d38..30041ea 100644 --- a/test/test-integration.php +++ b/test/test-integration.php @@ -1,5 +1,6 @@ getPDO(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Default from PHP 8 + $connection = $db->createConnection($pdo); + + expect(SQLException::class, 'pdo exception mode is handled', function () use ($connection, $db) { + $connection->fetch($db->sql('invalid syntax'))->firstCol(); + },['/42601: ERROR: syntax error/']); + } +); + test( 'can connect to MySQL', function () use ($config) {