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

Fix binding values #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marliotto
Copy link

Hello,
I've fixed rewriting values when values was been set through bindValue().
For example:

$statement = $this->connection->prepare('INSERT INTO test_insert_table(id, payload) VALUES (?, ?), (?, ?)');
$statement->bindValue(0, 7, ParameterType::INTEGER);
$statement->bindValue(1, 'v?7');
$statement->bindValue(2, 8, ParameterType::INTEGER);
$statement->bindValue(3, 'v8');

Result SQL:

INSERT INTO test_insert_table(id, payload) VALUES (7, 'v87'), ('v8', ?)

Fixed bug with keys that have the same prefix.
For example:

$statement = $this->connection->prepare('INSERT INTO test_insert_table(id, payload) VALUES (:v1, :v10)');
$statement->execute(['v1' => 1, 'v10' => 'v1');

Also, new solution supports keys like '?' and ':key' in one query.

@marliotto
Copy link
Author

Hello @mochalygin , @argayash ! Could you check my PR?
It will fix #22

@asanikovich asanikovich self-assigned this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants