Skip to content

[Bug]: TestPDOStatement::bindParam() and bindColumn() lose the reference #23

Open

Description

@roxblnfk

Describe the bug

TestPDOStatement::bindParam() and bindColumn() drop the by-reference binding. Both forward with $this->statement->bindParam(...\func_get_args()), and func_get_args() returns copies, so the inner statement binds a temporary instead of the caller's variable:

  • a value assigned to the variable after bindParam() never reaches the query;
  • a variable bound with bindColumn() is never filled on fetch.

Raw PDO behaves as expected in both cases.

Is this a regression?

No.

To Reproduce

$stmt = $pdo->prepare('SELECT ? AS v'); // $pdo is the harness's TestPDO
$v = 1;
$stmt->bindParam(1, $v);
$v = 2;
$stmt->execute();
$stmt->fetchColumn(); // 1 with TestPDOStatement, 2 with raw PDO

Expected behaviour

The same as \PDOStatement: pass $var by reference, e.g. $this->statement->bindParam($param, $var, $type, ...) with the remaining arguments forwarded explicitly.

Media prove

Not applicable.

Database

All of them.

Your environment

cycle/testing 1.x, src/Database/Mock/TestPDOStatement.php (bindParam(), bindColumn()).

Additional context

Found while raising coverage in #22. Nothing in the harness depends on it today: the only caller is SQL Server's LOB binding, which executes right after binding.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions