Can not insert data by the function saveAll with many model
I have a problem related to the function "SaveAll" in cakephp 1.2+ as the following:
I have 3 models: A, B, C that the relation is:
A belongTo B
B hasOne A
B belongTo C
C hasOne B
Above it means A,B,C all relation is 1-1
I have a form that includes all field of A,B,C to create new A,B,C. When saving, I can't create new A,B,C with the function SaveAll because when checking sql log of cake, the function SaveAll doesn't generate INSERT sql for model C
Pls开发者_JAVA技巧 help me resolve this problem ?
index.ctp
<?php echo $form->create('Customer',array('action' => 'customers/add'));
echo $form->input('Customer.name');
echo $form->radio('CustomerReview.comment');
echo $form->radio('CustomerRating.value');
?>
in customers_controller.php file
class CustomersController extends AppController {
var $name = 'Customers';
function index(){
$this->layout = 'site';
if(!empty($this->data)){
if($this->Customer->saveAll($this->data)){
$this->Session->setFlash('Thank you for the feedback!');
}
}
}
}
here Customer = A CustomerReview = B CustomerRating = C
精彩评论