Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCI8Statement::execute() ignores binding errors #3366

Closed
morozov opened this issue Nov 29, 2018 · 2 comments
Closed

OCI8Statement::execute() ignores binding errors #3366

morozov opened this issue Nov 29, 2018 · 2 comments

Comments

@morozov
Copy link
Member

morozov commented Nov 29, 2018

Q A
BC Break no
Version 2.8.0

Statement::bind*() methods return a boolean value to indicate whether the binding was successful:

* @return bool TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = ParameterType::STRING);

This value is ignored in other DBAL components. For instance:

if ($hasZeroIndex && is_numeric($key)) {
$this->bindValue($key + 1, $val);
} else {
$this->bindValue($key, $val);

It leads to the issues like:

use Doctrine\DBAL\DriverManager;

$conn = DriverManager::getConnection([
    'driver' => 'oci8',
    'host' => 'localhost',
    'user' => 'system',
    'password' => 'oracle',
    'dbname' => 'XE',
]);

$data = $conn->fetchAll('SELECT 1 FROM DUAL', [123]);

var_dump($data);

/*
Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number in lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php on line 316

array(1) {
  [0] =>
  array(1) {
    [1] =>
    string(1) "1"
  }
}
*/

Statement::execute() should throw an exception in the case of a binding error instead of trying to execute an incorrectly constructed query.

@Ocramius
Copy link
Member

Ocramius commented Dec 1, 2018

Handled in #3369

@Ocramius Ocramius closed this as completed Dec 1, 2018
@github-actions
Copy link

github-actions bot commented Aug 1, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants