I have the following sql query, how can I write the query in yii using findAll()
?
I am not using CDbCriteria
and for the time being avoiding it.
Using three tables user, category and job_profile.
SELECT *
FROM job_profile
INNER JOIN user ON user.id = job_profile.user_id
INNER JOIN category ON category.id = job_profile.category_id
WHERE category_id = 1
AND experience = 2
AND key_skills LIKE '%php%'
I have written the following queries but I do not know how to include join:
$results = SearchEmployee::model()->findAll("category_id=:category AND key_skills like
:skill AND experience=:experience", array(
'category'=>$category,
'skill'=>'%'.$skills.'%',
'experience'=>$experience
));
you can use queryAll with create command.
You can find relations names in your JobProfile model
Example for relations
There will be source code in your JobProfile Model File like
Here is 'user' is relation name...
then in your controller example;
Can you try this way: