Unverified Commit f37a88ed authored by Sergei Morozov's avatar Sergei Morozov

Merge branch '2.10'

parents 3e735a81 70666011
......@@ -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
......
......@@ -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:
- |
......@@ -311,3 +310,6 @@ jobs:
install:
- composer config minimum-stability dev
- travis_retry composer update --prefer-dist
allow_failures:
- env: DEPENDENCIES=dev
......@@ -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',
......@@ -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
......
......@@ -273,7 +273,13 @@ class OCI8Statement implements IteratorAggregate, Statement
*/
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);
......
......@@ -39,17 +39,41 @@ class StatementTest extends DbalFunctionalTestCase
);
}
/**
* 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],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment