で複雑なクエリを使用したいpaginate()
。これが私のコードです:
// PhasesController.php
public function manage($id = null) {
$this->loadModel('ProjectDomainPhasesUser');
$this->ProjectDomainPhasesUser->recursive = 0;
$this->paginate = array(
'ProjectDomainPhasesUser' => array(
'order' => array('Phase.label_'.$_SESSION['lang']),
'joins' => array(
array(
'table' => 'users',
'alias' => 'User',
'type' => 'INNER',
'foreignKey' => false,
'conditions'=> array(
'ProjectDomainPhasesUser.user_id = User.id AND User.id = '.$this->Auth->User('id')
)
),
array(
'table' => 'project_domains_phases',
'alias' => 'ProjectDomainsPhase',
'type' => 'INNER',
'foreignKey' => false,
'conditions'=> array(
'ProjectDomainsPhase.id = ProjectDomainPhasesUser.project_domain_phase_id'
)
),
array(
'table' => 'processes_phases',
'alias' => 'ProcessesPhase',
'type' => 'LEFT',
'foreignKey' => false,
'conditions'=> array(
'ProjectDomainsPhase.process_phase_id = ProcessesPhase.id'
)
),
array(
'table' => 'phases',
'alias' => 'Phase',
'type' => 'LEFT',
'foreignKey' => false,
'conditions'=> array(
'ProcessesPhase.phase_id = Phase.id'
)
),
array(
'table' => 'projects_domains',
'alias' => 'ProjectsDomain',
'type' => 'LEFT',
'foreignKey' => false,
'conditions'=> array(
'ProjectDomainsPhase.project_domain_id = ProjectsDomain.id'
)
),
array(
'table' => 'domains',
'alias' => 'Domain',
'type' => 'LEFT',
'foreignKey' => false,
'conditions'=> array(
'ProjectsDomain.domain_id = Domain.id'
)
),
array(
'table' => 'projects',
'alias' => 'Project',
'type' => 'LEFT',
'foreignKey' => false,
'conditions'=> array(
'ProjectsDomain.project_id = Project.id'
)
)
),
'fields' => array('Project.title', 'Project.date_target', 'ProcessesPhase.step_number', 'Domain.label_fr AS domain_fr', 'Domain.label_es AS domain_es', 'Phase.label_fr AS phase_fr', 'Phase.label_es AS phase_es', 'ProjectDomainsPhase.date_notification', 'ProjectDomainsPhase.done', 'ProjectDomainsPhase.date_finished', 'ProjectDomainsPhase.id')
)
);
$this->set('taches', $this->paginate());
これは、cakephp: 検索結果に結合を使用して作成しました
私の見解 :
// manage.ctp
<table cellpadding="8" cellspacing="0">
<tr>
<th><?php echo $this->Paginator->sort('Project.title','Projet'); ?></th>
<th><?php echo $this->Paginator->sort('Project.date_target','Date cible du projet'); ?></th>
<th><?php echo $this->Paginator->sort('ProcessesPhase.step_number','Etape'); ?></th>
<th><?php echo $this->Paginator->sort('Domain.domain_'.$_SESSION['lang'],'Domaine'); ?></th>
<th><?php echo $this->Paginator->sort('Phase.phase_'.$_SESSION['lang'],'Tâche'); ?></th>
<th><?php echo $this->Paginator->sort('ProjectDomainsPhase.date_notification','Date notification'); ?></th>
<th><?php echo __('Statut'); ?></th>
<th><?php echo $this->Paginator->sort('ProjectDomainsPhase.date_finished','Date fin tâche'); ?></th>
</tr>
<?php
foreach ($taches as $key => $tache){ ?>
<tr>
<td><?php echo $tache['Project']['title']; ?> </td>
<td><?php echo $this->Date->date_inv($tache['Project']['date_target']); ?> </td>
<td><?php echo $tache['ProcessesPhase']['step_number']; ?> </td>
<td><?php echo $tache['Domain']['domain_'.$_SESSION['lang']]; ?> </td>
<td><?php echo $tache['Phase']['phase_'.$_SESSION['lang']]; ?> </td>
<td><?php echo $this->Date->date_inv($tache['ProjectDomainsPhase']['date_notification']); ?> </td>
<td><?php
echo '<input type="hidden" name="data['.$key.'][ProjectDomainsPhase][done]" value=0 />';
echo '<input type="checkbox" name="data['.$key.'][ProjectDomainsPhase][done]" value="1"';
if ($tache['ProjectDomainsPhase']['done']==1)
echo ' checked';
echo ' />';
echo '<input type="hidden" name="data['.$key.'][ProjectDomainsPhase][id]" value='.$tache['ProjectDomainsPhase']['id'].' />';
?> </td>
<td><?php echo $this->Date->date_inv($tache['ProjectDomainsPhase']['date_finished']); ?> </td>
</tr>
<?php };
?>
</table>
私の問題は、私の見解では、すべてのデータは素晴らしいですが、列をクリックしてソートしようとすると、ページがリロードされますが、何も変わらないということです。