Skip to content

Commit

Permalink
Merge branch '2.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jan 2, 2020
2 parents 3e735a8 + 7066601 commit f37a88e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ install:
}
# install composer dependencies
- cd C:\projects\dbal
- rm composer.lock
- appveyor-retry composer self-update
- appveyor-retry composer install --no-progress --prefer-dist

Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ before_script:
- if [[ "$DB" == "mysql" || "$DB" == "mysqli" || "$DB" == *"mariadb"* ]]; then mysql < tests/travis/create-mysql-schema.sql; fi;

install:
- rm composer.lock
- travis_retry composer -n update --prefer-dist
- travis_retry composer -n install --prefer-dist

script:
- |
Expand Down Expand Up @@ -311,3 +310,6 @@ jobs:
install:
- composer config minimum-stability dev
- travis_retry composer update --prefer-dist

allow_failures:
- env: DEPENDENCIES=dev
6 changes: 2 additions & 4 deletions docs/en/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ You can get a DBAL Connection through the
.. code-block:: php
<?php
$config = new \Doctrine\DBAL\Configuration();
//..
$connectionParams = array(
'dbname' => 'mydb',
Expand All @@ -19,19 +18,18 @@ You can get a DBAL Connection through the
'host' => 'localhost',
'driver' => 'pdo_mysql',
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
Or, using the simpler URL form:

.. code-block:: php
<?php
$config = new \Doctrine\DBAL\Configuration();
//..
$connectionParams = array(
'url' => 'mysql://user:secret@localhost/mydb',
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
The ``DriverManager`` returns an instance of
``Doctrine\DBAL\Connection`` which is a wrapper around the
Expand Down
8 changes: 7 additions & 1 deletion lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ public function bindValue($param, $value, int $type = ParameterType::STRING) : v
*/
public function bindParam($param, &$variable, int $type = ParameterType::STRING, ?int $length = null) : void
{
$param = $this->_paramMap[$param];
if (is_int($param)) {
if (! isset($this->_paramMap[$param])) {
throw new OCI8Exception(sprintf('Could not find variable mapping with index %d, in the SQL statement', $param));
}

$param = $this->_paramMap[$param];
}

if ($type === ParameterType::LARGE_OBJECT) {
$lob = oci_new_descriptor($this->_dbh, OCI_D_LOB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,41 @@ public function testQueryConversion(string $query, array $params, array $expecte
);
}

/**
* Low-level approach to working with parameter binding
*
* @param mixed[] $params
* @param mixed[] $expected
*
* @dataProvider queryConversionProvider
*/
public function testStatementBindParameters(string $query, array $params, array $expected) : void
{
$stmt = $this->connection->prepare($query);
$stmt->execute($params);

self::assertEquals(
$expected,
$stmt->fetch()
);
}

/**
* @return array<string, array<int, mixed>>
*/
public static function queryConversionProvider() : iterable
{
return [
'simple' => [
'positional' => [
'SELECT ? COL1 FROM DUAL',
[1],
['COL1' => 1],
],
'named' => [
'SELECT :COL COL1 FROM DUAL',
[':COL' => 1],
['COL1' => 1],
],
'literal-with-placeholder' => [
"SELECT '?' COL1, ? COL2 FROM DUAL",
[2],
Expand Down

0 comments on commit f37a88e

Please sign in to comment.