
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 1.23 KB | hits: 32 | expires: Never
Cakephp paginate with join
$this->paginate['Report']['joins'] =
array(
array(
'table' => 'issues',
'alias' => 'Issue',
'type' => 'INNER',
'conditions' => array(
'Report.id = Issue.report_id',
)
)
);
class Report extends AppModel {
var $name = 'Report';
var $hasMany = array(
'File' => array(
'className' => 'File',
'foreignKey' => 'report_id',
),
'Employee' => array(
'className' => 'Employee',
'foreignKey' => 'report_id',
),
'Issue' => array(
'className' => 'Issue',
'foreignKey' => 'report_id',
)
);
class Issue extends AppModel {
var $name = 'Issue';
var $belongsTo = array(
'Report' => array(
'className' => 'Report',
'foreignKey' => 'report_id',
)
);
class Employee extends AppModel {
var $name = 'Employee';
var $belongsTo = array(
'Report' => array(
'className' => 'Report',
'foreignKey' => 'report_id',
)
);
class File extends AppModel {
var $name = 'File';
var $belongsTo = array(
'Report' => array(
'className' => 'Report',
'foreignKey' => 'report_id',
)
);