-1
我用cakephp控制檯生成一些CRUD操作。生成的代碼很麻煩,因爲相關模型的模型在控制器中未默認加載。相關模型未加載由代碼生成的代碼php控制檯
例如:
$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' => ''
),
);
一些關聯被刪除,因爲stackoverflow想要更少的代碼。 – 2012-07-13 19:31:02
和你的問題是什麼? – pollirrata 2012-07-13 19:38:37