我使用 cakephp 控制台生成了一些 CRUD 操作。生成的代码有问题,因为默认情况下未在控制器中加载关联模型的模型。
例如:
$programs = $this->Chantier->Program->find('list');
行不通,但是:
$this->loadModel('Program');
$programs = $this->Program->find('list');
将。这是关联的代码:
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Programs' => array(
'className' => 'Programs',
'foreignKey' => 'Programs_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Etats' => array(
'className' => 'Etats',
'foreignKey' => 'Etats_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Types' => array(
'className' => 'Types',
'foreignKey' => 'Types_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'ChampsLibres' => array(
'className' => 'ChampsLibres',
'foreignKey' => 'Champs_libres_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);