Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // into controller
- $this->Jobcategory->find('all', array(
- 'contains' => array('UsersJobcategory'),
- 'recursive' => 1,
- 'conditions' => array(
- 'UsersJobcategory.type' => 'favorite',
- ),
- 'fields' => array(
- 'UsersJobcategory.*'
- )
- ));
- // SQL query
- SELECT `Jobcategory`.`id`, `Jobcategory`.`category`, `Jobcategory`.`parent_category_id`, `Jobcategory`.`domain_id`, `Jobcategory`.`active`, `Jobcategory`.`created`, `Jobcategory`.`modified` FROM `jobcategories` AS `Jobcategory` WHERE `UsersJobcategory`.`type` = 'favorite'
- // Jobcategory model
- class Jobcategory extends AppModel {
- var $name = 'Jobcategory';
- var $recursive = 1;
- var $hasMany = array(
- 'UsersJobcategory' => array(
- 'className' => 'UsersJobcategory',
- 'foreignKey' => 'jobcategory_id'
- )
- );
- // UsersJobcategory
- class UsersJobcategory extends AppModel {
- var $name = 'UsersJobcategory';
- var $belongsTo = array(
- 'Jobcategory' => array(
- 'className' => 'Jobcategory',
- 'foreignKey' => 'jobcategory_id'
- )
- );
- // AppModel
- class AppModel extends Model {
- var $actsAs = array('Containable', 'Linkable.Linkable');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement