-
Notifications
You must be signed in to change notification settings - Fork 375
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
implemented emulate prepare and added tests #371
Conversation
Thaaaaanks!! Just a question... What happens with duplicate placeholders in the updated implementation? On the previous driver you could not have a placeholder twice, yet on other PDO drivers such as MySQL they will let you re-use parameteres by allowing a placeholder to be repeated. |
Can you clarify on what you mean by duplicated placeholders? Do you mean having two placeholders with the same name in a sql query?
And both ':id' placeholders in the sql query is replaced with 1234. Or do you mean binding to the same placeholder twice?
|
I'm talking about your first example werwe the placeholder is present twice in the query itself. |
I did some preliminary testing. Seems like duplicated placeholders works for parameters of any encoding types that's not binary. |
…ses through each acceptable characters to using if else statement that covers a range of characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
source/pdo_sqlsrv/pdo_dbh.cpp
Outdated
|
||
// get the current object in PHP; this distinguishes pdo_sqlsrv_dbh_quote being called from: | ||
// 1. PDO::quote() - object name is PDO | ||
// 2. PDO::execute() - object name is PDOStatement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant PDOStatement::execute 😉
Fix for #92 and #140 .
Implement emulate prepare by:
Note: Emulate prepare only works for input bound parameters.
When user specify PDO::PARAM_INPUT_OUTPUT in PDO::bindParam when emulate prepare is on, the driver throws a PDO exception.
When user binds an output parameter, the sql query should be a placeholder preceding an '=' sign (e.g., "SELECT ? = COUNT(*) FROM Employee WHERE Department='Human Resources'"). When while parsing out the placeholders out from the sql string, it also checks if the sql query has an '=' immediately after a placeholder. If it does, throws an exception saying output parameter with emulate prepared statement is not supported. If user binds an output parameter to a stored procedure, an error would not be raise.