2016-05-11 4 views
2

ich ein Problem in cakephp pagination.Before habe ich kam tief würde Ich mag einige Code anzuzeigen, die ich in meinem Controllerwie in cakephp Paginieren, wenn Ergebnis kommt von mehreren Bedingungen beitreten

$this->paginate = array(
'joins' => array(
       array(
         'table' => 'job_posting_lists', 

         'conditions'=> array('job_posting_lists.firm_id')), 
         array(
         'table' => 'firmsdetails', 
         'alias' => 'st', 
         'conditions'=> array('st.id')), 
       ),    
      'conditions' =>array('job_posting_lists.select_industry'=>$id,'job_posting_lists.verify'=>1), 
      'fields' => array('job_posting_lists.*','st.*'), 
      'limit' => 3, 

      'contain' => array('job_posting_lists')); 

     $ListjobBycategories = $this->paginate(); 
     echo "<pre>";print_r($ListjobBycategories); die; 
     $this->set('jobbycat',$ListjobBycategories); 

das Ergebnis kommen in ListjobBycategories richtig, aber es mehr Daten über 1230 und in meinem job_posting_datas gibt nur 5 Zeilen die nächste Seite Rückkehr gleiche Ergebnis, was ich tun

+0

Ich möchte $ ListjobBycategories Daten – user5876330

Antwort

1

diesen Code Versuchen sie, entsprechende Änderungen nach Ihren Code zu machen,

$this->paginate = array(
    'joins' => array(
      array(
      'table' => 'tbl1', 
      'alias' => 'alias1', 
      'conditions'=> array('') 
     ),array(
      'table' => 'tbl2', 
      'alias' => 'alias2', 
      'conditions'=> array('') 
     ),array(
      'table' => 'tbl3', 
      'alias' => 'alias3', 
      'type' => 'left', 
      'conditions'=> array('') 
     ), 
     ),    
       'conditions' => $displayConditions, // Your query conditions 
       'fields' => $this->displayFields, // Your field set which you want to retrieve from tables 
       'limit' => $show_page,// number of records you wish to retrieve in each page 
       'group' => '', // field by which wish to grouping your data set 
       'contain' => array(''),//It will contain name of all the Models which are in Join 
      ); 

      $ListjobBycategories = $this->paginate(); // Call pagination function, it will retrieve all records 

Lassen Sie mich wissen, wenn eine Frage.

+0

in Bedingung, deren Bedingung gebe ich entweder Join-Bedingung oder Hauptbedingungen geben – user5876330

+0

Condition wird 'Main-Bedingungen' enthalten, für Joins müssen Sie ein anderes Element 'Joins' hinzufügen und fügen Sie Ihre Join-Bedingungen dort. – Chandresh

+0

Bitte überprüfen Sie meine bearbeitete Antwort jetzt. Ich denke, es wird Ihnen besser helfen – Chandresh

Verwandte Themen