Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 1.23 KB  |  hits: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Cakephp paginate with join
  2. $this->paginate['Report']['joins'] =
  3.     array(
  4.         array(
  5.             'table' => 'issues',
  6.             'alias' => 'Issue',
  7.             'type' => 'INNER',
  8.             'conditions' => array(
  9.                 'Report.id = Issue.report_id',
  10.             )
  11.         )
  12.     );
  13.        
  14. class Report extends AppModel {
  15. var $name = 'Report';
  16.  
  17. var $hasMany = array(
  18.     'File' => array(
  19.         'className' => 'File',
  20.         'foreignKey' => 'report_id',
  21. ),
  22.     'Employee' => array(
  23.         'className' => 'Employee',
  24.         'foreignKey' => 'report_id',
  25. ),
  26.     'Issue' => array(
  27.         'className' => 'Issue',
  28.         'foreignKey' => 'report_id',
  29.     )
  30.  
  31. );
  32.        
  33. class Issue extends AppModel {
  34.     var $name = 'Issue';
  35.     var $belongsTo = array(
  36.         'Report' => array(
  37.             'className' => 'Report',
  38.             'foreignKey' => 'report_id',
  39.     )
  40.     );
  41.        
  42. class Employee extends AppModel {
  43. var $name = 'Employee';
  44.  
  45.  
  46. var $belongsTo = array(
  47.     'Report' => array(
  48.         'className' => 'Report',
  49.         'foreignKey' => 'report_id',
  50. )
  51. );
  52.        
  53. class File extends AppModel {
  54.  
  55. var $name = 'File';
  56.  
  57. var $belongsTo = array(
  58.         'Report' => array(
  59.             'className' => 'Report',
  60.             'foreignKey' => 'report_id',
  61. )
  62. );