Need a corresponding Cake PHP query using find() for my SQL

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
devilinc
Forum Newbie
Posts: 16
Joined: Fri Nov 12, 2010 1:07 am

Need a corresponding Cake PHP query using find() for my SQL

Post 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!!!
devilinc
Forum Newbie
Posts: 16
Joined: Fri Nov 12, 2010 1:07 am

Re: Need a corresponding Cake PHP query using find() for my

Post 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));
devilinc
Forum Newbie
Posts: 16
Joined: Fri Nov 12, 2010 1:07 am

Re: Need a corresponding Cake PHP query using find() for my

Post by devilinc »

I think the query is good enough for simple search
Post Reply