I created a registration form and submit the data to the controller.
I want to insert this data into 3 different tables (models).
How can this be achieved?
As long as your forms are formatted in accordance with the CakePHP conventions, and the relationships between the models are configured correctly, this will be done automatically when called $this->Model->save($this->data).
$this->Model->save($this->data)
What you mean (in CakePHP terms) is that you want to use more models than the default. The default model is the one called your controller.
, $uses . :
$uses
<?php class ExampleController extends AppController { var $name = 'Example'; // $uses is where you specify which models this controller uses var $uses = array('Model1', 'Model2', 'ModelN'); // ... here go your controller actions (methods) } ?>
Model1, Model2 ModelN. .
Model1
Model2
ModelN
, $uses , :
var $uses = array();
CakePHP , :
controller::$uses
" ", , .
$this->loadModel('Model1');
.
, . :
$this->Model1->Model2->find();
Containable and Relationships (HasMany, BelongsTo, HABTM)