Page 1 of 1
Need a corresponding Cake PHP query using find() for my SQL
Posted: Thu Dec 16, 2010 12:15 am
by devilinc
I need someone to translate this into CakePHP style....dont want to use normal queries.....
Code: Select all
SELECT * FROM `departments` WHERE `department_name` LIKE '%hi%' OR `department_email LIKE '%hi%'
here i use the email or name from a text field input so i will handle it but if u could just translate this it into cakephp thanks a lot!!!
Re: Need a corresponding Cake PHP query using find() for my
Posted: Thu Dec 16, 2010 12:29 am
by devilinc
this is how far i have reached...could anyone advise me if i have written something wrong?
Code: Select all
$conditions = array( "OR" => array (
"department_name LIKE" => "%".$this->data['Department']['department_search']."%",
"department_email LIKE" => "%".$this->data['Department']['department_search']."%"
)
);
$search_results = $this->Department->find('all', array('conditions' => $conditions));
Re: Need a corresponding Cake PHP query using find() for my
Posted: Thu Dec 16, 2010 3:00 am
by devilinc
I think the query is good enough for simple search