-
Notifications
You must be signed in to change notification settings - Fork 66
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
add named parameter #43
base: 0.7.x
Are you sure you want to change the base?
Conversation
... and TODO comment in "Binary" -> because of missing class
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.
Thank you very much for providing this PR!
I wonder if it makes sense to accept multiple arguments with an array each or maybe limit this to a single argument array à la bindParamsFromArray()
? Also, the method definition being public
and returning an array
looks a bit odd to me. What do you think about this? 👍
e.g. composer -> "could not be downloaded (HTTP/1.1 404 Not Found)
Hi, method definition is |
Hi @voku and @clue, can I ask why this is stagnant? If you don't mind, I have some thoughts on the suggested implementation. It doesn't allow multiple uses of a token.$query = new Query('select * from test where name = :id or id = :id');
$sql = $query->bindParamsFromArray([':id' => 2])->getSql();
$this->assertEquals("select * from test where name = 2 or id = 2", $sql); This will only replace the first token, not the subsequent ones. -'select * from test where name = 2 or id = 2'
+'select * from test where name = 2 or id = :id' It is not string aware.$query = new Query('select * from test where name = ? or id = :id');
$sql = $query->bindParamsFromArray(["I'm a code sample like self::identify()", ':id' => 2])->getSql();
$this->assertEquals("select * from test where name = 'I'm a code sample self::identify()' or id = 2", $sql); -'select * from test where name = 'I'm a code sample self::identify()' or id = 2'
+'select * from test where name = 'I\'m a code sample like self:2entify()' or id = :id' That said, I would like to see this implemented, and could help out. One thought is to use a SQL lexer like https://packagist.org/packages/phpmyadmin/sql-parser#4.3.2 to tokenize the SQL to make it easier to replace on only the token parts and/or validate the SQL. |
#41