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