1
我有一个名为'year'的字段的表。它有很多重复的列,所以我想找到不同的组。我在大约20行中有4个不同的“年份”,我没有从查询中获得这些值。取而代之的是4个不是年份的数字(5,14,4,70)。当我在另一个表中有这个字段的多个值的郊区字段中使用此代码时,相同的代码正常工作。我不明白为什么这不是工作。无法从cakephp3中的查询获取int字段的组
//in view
echo $this->Form->input('year', ['label' => 'Year','options' => $allyears]);
//controller
$allyears = $this->TimesheetDates->find('list')
->select(['TimesheetDates.id', 'TimesheetDates.year'])
->group(['TimesheetDates.year'])->autoFields(true)
->order(['TimesheetDates.year'=> 'ASC'])
->hydrate(false);
$this->set('allyears',$allyears);
//another controller and this code worked fine
$suburb = $this->Students->find('list')->where(['Students.address_suburb !=' => '','Students.student_inactive' => 0])
->select(['Students.id','Students.address_suburb'])
->group(['Students.address_suburb'])->autoFields(true)
->order(['Students.address_suburb' => 'ASC'])
->hydrate(false);
这是'(5,14,4,70)'ID? – Poonam
不是这不是组中的ID或年数 – ajt