Skip to content

Conversation

HosseyNJF
Copy link

Fix 'SQLSTATE[HY093]: Invalid parameter number' PDO error which caused of multiple parameters usage in one query.

@noplanman
Copy link
Member

Thanks for your contribution!

What version of MySQL are you using, I have never encountered this issue.

@HosseyNJF
Copy link
Author

HosseyNJF commented Apr 15, 2017

I'm using lumen framework. MySQL version: 5.1.73 (this error came from the pdo plugin itself, not mysql) (i gave the lumen's eloquent's pdo object to this package).

@HosseyNJF
Copy link
Author

why u dont merge it ?

@noplanman
Copy link
Member

Hi, sorry for the epic delay...

A cleaner solution in my view, is to simply rename the fields to created_date and updated_date respectively.

Also, your ON DUPLICATE KEY section saves the wrong value to updated_at, as it simply puts the value of created_at into the updated_at field, instead of the current timestamp.

If you could change it accordingly and do the same for all other instances of duplicate :date tokens in other queries, I'll happily merge 😃

@noplanman
Copy link
Member

@no-nevis Shall I go ahead and make the changes and merge?

@HosseyNJF
Copy link
Author

HosseyNJF commented May 1, 2017

Also, your ON DUPLICATE KEY section saves the wrong value to updated_at, as it simply puts the value of created_at into the updated_at field, instead of the current timestamp.

Fixed.

A cleaner solution in my view, is to simply rename the fields to created_date and updated_date respectively.

The problem isn't only dates, but the other placeholders that used twice.

If you could change it accordingly and do the same for all other instances of duplicate :date tokens in other queries, I'll happily merge 😃

I searched and there is no any other duplicate usage.

no-nevis and others added 3 commits May 1, 2017 21:36
Fix 'SQLSTATE[HY093]: Invalid parameter number' PDO error which caused of multiple parameters usage in one query.
@noplanman
Copy link
Member

Hi @no-nevis

I have taken the liberty to rebase your PR properly, to prevent the duplicate commits that snuck in.

Also, I've added another commit that renames the placeholders to make it more obvious and cleaner.

There is 1 query left that has duplicate (or rather triplicate) placeholders here:
https://github.com/no-nevis/core/blob/patch-1/src/DB.php#L1104

Is this one an issue for you too? Do you get the same error?

@noplanman noplanman merged commit 8e5308c into php-telegram-bot:develop May 3, 2017
@noplanman
Copy link
Member

Thanks @no-nevis 😃👍

@HosseyNJF HosseyNJF deleted the patch-1 branch May 4, 2017 15:56
@sana8237
Copy link

sana8237 commented May 8, 2017

Delete

noplanman added a commit to noplanman/php-telegram-bot that referenced this pull request Aug 19, 2017
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.

3 participants