How to use AND and OR conditions in cakephp find function


Posted on 06 Nov 15 by Vickey

In cakephp find function we add conditions like this

$Mymodeldata=$this->Mymodel->find('first', array(
	'conditions'=>array('Mymodel.column1' => 2,'Mymodel.column2' => 5)

But in this code we have only 'AND' conditions. like in this sql query

'SELECT * FROM mytable WHERE column1=2 AND column2=5'

if you want to add 'AND' and 'OR' conditions both you can use the below code

$Mymodeldata=$this->Mymodel->find('first', array(
			'Mymodel.column1' => 2,
			'Mymodel.column2' => 5


If this post help you reduce time to develop, you can help me to maintain this website :)