Hi everyone!
I am trying to create a sql query with multiples conditions, but despite I have readen all the the information about it I am not able to allow my code works.
I have the following sql code:
$query=Yii::app()->db->createCommand()
->select('*')
->from('articulos')
->where (['and', 'premium=Premium', 'estadoNoticia=Publicada' ])
->order('fecha DESC')
->limit(3)
->queryAll();
The problem of this code is that despite I have a column called premium in my sql database, and another one called estadoNoticia, Yii fwk throws the following error:
I attach an image with my table structure.
Finally, what if I want to do an or condition plus and and condition? I mean, how I have to writte in yii the sql statement to throw the next query?
Select *
from articulos
where (estadoNoticia=Publicada) AND (seccion=Nacional) AND (premium=Premium) or (premium=1)
order by fecha desc
limit 3;
Thank you very much!!