我想使用一个复杂的查询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());
我的观点 :
// 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>
我的问题是,在我看来,所有数据都很棒,但是当我尝试排序时,通过单击一列,页面重新加载但没有任何变化。