我有两个表ecategory(id,name,parent_id)和technical_detail(id,tech_interview_id,category_id)
technical_details将category_id作为ecategory表的外键。
如何使用cakePHP 3生成显示技术详细信息表中相应评级的类别树(父子)。
$this->Ecategory->recursive = 2;
$cond['conditions'] = array('Ecategory.parent_id' => 0);
$ecategories = $this->Ecategory->find('all', $cond);
foreach ($ecategories as $k => $row) {
$cat_ids[] = $row['Ecategory']['id'];
}
$cond['conditions'] = array('Technicaldetail.category_id in' => $cat_ids);
$technicalDetails = $this->Technicaldetail->find('all', $cond);