0
連接表的hasMany我想用hasMany through
關係通過一個模型來連接兩個users
invitations
CakePHP的如何通過另一種定義兩個相同型號的通過
目前,我有以下控制器:
class User extends AppModel {
var $name = 'User';
var $displayField = 'username';
var $hasMany = array(
'Invitation' => array(
'className' => 'Invitation',
'foreignKey' => 'sender_user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Invitation' => array(
'className' => 'Invitation',
'foreignKey' => 'receiver_user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
)
}
然而,當我得到的錯誤:
Error: Database table sender_users for model SenderUser was not found.
這是一個有點討厭,因爲我已經日應該指定我想用Invitation
。
什麼問題,我要更改哪些代碼?
是的,這有幫助。另外,Invitations模型中的自動生成的MODEL具有''className'=>'SenderUser','而不是''className'=>'User','。現在都好了:) – mgPePe