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

Named placeholder don't work in where() #193

Open
gugglegum opened this issue Jan 8, 2022 · 1 comment
Open

Named placeholder don't work in where() #193

gugglegum opened this issue Jan 8, 2022 · 1 comment

Comments

@gugglegum
Copy link

The documentation in examles allow to used named placeholders in where clause like this:

// bind 'zim_val' to the :zim placeholder
->where('zim = :zim', ['zim' => 'zim_val'])

But this will not work since named placeholders don't update bind_values internal property. The ->where() method only works with ?-placeholders which actually not documented at all. I've lost 2 hours trying to figure it out.

$select = $queryFactory->newSelect()->cols(['*'])->from('table1')->where('col1 = :col1', ['col1' => 'value']);
var_dump($select->getStatement());
var_dump($select->getBindValues());

This will print SQL query and empty array of bind values.

Possible workaround could be using of additional bindValues():

$select = $queryFactory->newSelect()->cols(['*'])->from('table1')->where('col1 = :col1')->bindValues(['col1' => 'value']);
var_dump($select->getStatement());
var_dump($select->getBindValues());

or using ?-placeholder:

$select = $queryFactory->newSelect()->cols(['*'])->from('table1')->where('col1 = ?', 'value');
var_dump($select->getStatement());
var_dump($select->getBindValues());

But both variants looks dirty and not match documentation.

P.S. Is this repo abandoned?

@harikt
Copy link
Member

harikt commented May 21, 2022

I am assuming you are using 3.x and this is related to the PR #142 .

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