On PeoplesController.php, I wanted to add the Events table by left join, Could someone guide me as i am still learning. Here's the original and working code.
public function constructClasses() {
parent::constructClasses();
$this->loadModel('People');
$this->loadModel('Event');
}
public function view() {
$num_per_page = 8;
if($tab == "images") {
$conditions = array();
$this->paginate['Tagged'] = array(
'tagged',
'model' => 'Image',
'by' => $people['People']['slug'],
'conditions' => $conditions,
'order' => array('Image.created'=>'DESC'),
'limit' => $num_per_page,
'paramType' => 'querystring',
);
$related = $this->paginate('Tagged');
}
}
here's the output:
array(
(int) 0 => array(
'Image' => array(
'object_id' => '1098',
)
),
....
....
(int) 7 => array(
'Image' => array(
'object_id' => '1082',
)
)
)
the goal is to get the slug from the events table by left join Event.id = Image.object_id
Events table
-----------------------
id | slug
-----------------------
1098 | slug-of-1098
1082 | slug-of-1082
Goal Output:
array(
(int) 0 => array(
'Image' => array(
'object_id' => '1098',
'slug' => 'slug-of-1098'
)
),
....
....
(int) 7 => array(
'Image' => array(
'object_id' => '1082',
'slug' => 'slug-of-1082'
)
)
)