Multiple Where Clause And Params

Hi,

What’s the correct way to use multiple where clauses and pass parameters to the conditions. I’m looking at the docs, which are good, but I’m clearly doing something wrong. As I’m getting the error in the title.




->where([ 

's.id' => ':id',

'j.live' => 1]

)

->addParams([':id'=>$id])		



Thanks

Jonny

Ended up doing this:




->where('s.id = :id')

->addParams([':id'=>$id])

->andwhere('j.live=:live', [':live' => 1])			  



If that is ok?

Also: Here at the bottom of this section: https://github.com/yiisoft/yii2/blob/master/docs/guide/query-builder.md#specifying-select-conditions

It says:

But the code example below goes on to use "addwhere"

Your way is correct but to fix the first version, just do it this way:




->where([ 

's.id' => $id,

'j.live' => 1]

)



No need to use params when you use the array variant.

this was a typo. I just fixed it.