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

placeholders question #97

Open
sinticbolivia opened this issue Apr 20, 2018 · 3 comments
Open

placeholders question #97

sinticbolivia opened this issue Apr 20, 2018 · 3 comments

Comments

@sinticbolivia
Copy link

Hello
Thanks for great work!!
But i have a question. Why the query builder returns the SQL string with just place holder and not with values intead
I mean
$query->where()->equals('id', 100);
SELECT * FROM users WHERE id = :v1
and why not
SELECT * FROM users WHERE id = 100

Regards,

@oscarteg
Copy link

oscarteg commented Jul 20, 2018

I think this is intended. There are a lot of ways to replace the variables with the values. When using PDO you can use something like prepare to replace the variables with the value and when using mysqli you can use something like bind_param. I think it's intended to let the user define the way to replace it and the library is not tightly coupled to an implementation.

@marcus-hiles
Copy link

Yeah I've been wondering about that myself @sinticbolivia
And even after you use prepare and bind_param it still doesn't give you the sql query with the values inserted. This feature will be good for debugging purposes @oscarteg

@nitricware
Copy link

nitricware commented Jul 21, 2019

I added a pull request (#109) that addresses this issue. Maybe I got the mechanism all wrong but maybe it helps you.

EDIT: never mind, I used the software wrong...

$s = $builder->select()->setTable('test')->where()->equals("id", $someID)->end();
$pdo->prepare($s);
$pdo->execute($builder->getValues());
$r = $pdo->fetchAll();

That's about the way to go, I guess...

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

4 participants