我有一个模型用户:
public $hasMany = array(
'Contact' => array('dependent' => true));
public $hasAndBelongsToMany = array(
'MySharepermission' => array(
'unigue' => false,
'className' => 'Contact',
'joinTable' => 'sharepermissions_users',
));
和模特联系
public $belongsTo = array('User');
public $hasAndBelongsToMany = array(
'Sharepermission' => array(
'unigue' => false,
'className' => 'User',
'joinTable' => 'sharepermissions_users',
)
);
现在我有一个 $data 数组:
array(
(int) 0 => array(
'Contact' => array(
'id' => '51254509-0654-468b-8007-1683550d8ff8'
),
'Sharepermission' => array(
'id' => '5123a3c3-d5ac-4541-b28b-326c550d8ff8',
'permission' => 'read'
)
),
(int) 1 => array(
'Contact' => array(
'id' => '51254509-0654-468b-8007-1683550d8ff8'
),
'Sharepermission' => array(
'id' => '51252eba-8804-40e7-bf3d-7db9550d8ff8',
'permission' => 'write'
)
)
)
数据库目前是空的,现在我这样做:
debug($this->Contact->saveAll($data));
结果很奇怪:
为什么呢?