如何从技术详细信息表中生成显示相应评级的类别树

时间:2018-05-11 10:44:53

标签: cakephp-2.3

我有两个表ecategory(id,name,parent_id)和technical_detail(id,tech_interview_id,category_id)

technical_details将category_id作为ecategory表的外键。

如何使用cakePHP 3生成显示技术详细信息表中相应评级的类别树(父子)。

Ecategory

technical_details

$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);

0 个答案:

没有答案