placeholders question
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,
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.
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
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...