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

Query binding stopped working #781

Closed
nowackipawel opened this issue Oct 17, 2017 · 1 comment
Closed

Query binding stopped working #781

nowackipawel opened this issue Oct 17, 2017 · 1 comment

Comments

@nowackipawel
Copy link
Contributor

nowackipawel commented Oct 17, 2017

TL;DR;
https://bcit-ci.github.io/CodeIgniter4/database/queries.html#query-bindings should be updated.


Simple query like this: $tmp = $this->query("SELECT :sth", [':sth' => 'abc']); is causing an exception now.

system/Database/Query.php->matchNamedBinds L: 421
Looks like query binding stopped working because of someone commented that line:
// $sql = preg_replace('|:' . $placeholder . '(?!\w)|', $escapedValue, $sql);
and there is also one missing char:

$sql = preg_replace('|:' . $placeholder . '(?!\w):|', $escapedValue, $sql);

UPDATE

Ok it works if we are binding like this:
SELECT :sth: instead of SELECT :sth .
So I think documentation should be updated (https://bcit-ci.github.io/CodeIgniter4/database/queries.html#query-bindings) or someone add one unnecessary ":" at the end:
$replacers[":{$placeholder}:"] = $escapedValue;
after placeholder.

@JakeAi
Copy link
Contributor

JakeAi commented Oct 17, 2017

@nowackipawel This was changed due to #655

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

No branches or pull requests

2 participants