I have created a registration form and I send data to the controller.
I want to insert this data to 3 different tables (models).
How can this be achieved?
What you mean (in CakePHP terms) is that you want to use more models than the default one. the default model is the one named like your controller.
To achieve what you want you just declare a variable $uses
in your controller. It's done like this:
<?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)
}
?>
This will allow your controller to make use of Model1
, Model2
and ModelN
. Rename those and add more according to your needs.
If you do not wish to use models in your controller, you can assign $uses
to an empty array, i.e.:
var $uses = array();
Take a look at the corresponding CakePHP book chapters according to the version you're using:
controller::$uses
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With