Currently i have 2 models. Users and Appbreak. They have associations of Users has many appbreak. Appbreaks belongs to users In my appbreak controller, there is a approve function which is called when a button from the view page is pressed.
In this function, i will need to update a value in the table of appbreak and a value in users table. I'm able to update value in appbreak by using the following:
$this->Appbreak->id = $id;
$this->Appbreak->set('approve', 'Yes');
$this->Appbreak->save();
However, i'm unable to pull the required data value from users table. <-- need to do so as i need to do some calculations before passing back the calculated value.
Am i able to get data from another model using the request method? Or do i need to use the find method? If i use the find method, am i able to update the the values and save it back into the database?
You can use any number of models in a controller . Declare the 'uses' array in controller
<?php
class DemoController extends AppController{
public $uses=array('Appbreak','User');
}
?>
To get data from AppBreak
model use find method of$this->AppBreak
object
Similarly to get data for User
use find method of$this->User
object
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