如何在cakephp3.x.x中通过外键查找字段?

时间:2014-12-31 09:00:26

标签: php cakephp foreign-key-relationship cakephp-3.0 cakephp-model

My index.ctp is like this

My Sample Database Design

如何尝试这样,我已经像这样写了ItemsTable.php

public function initialize(array $config) {
        $this->belongsTo('Categories', [
            'className' => 'Item',
            'foreignKey' => 'cid',
            'propertyName' => 'name'
        ]);
}

如何显示类别名称而不是Cid

0 个答案:

没有答案