I am in a Model1 (Model1)and I need to run some business logic that should update a record in the Model2 (table2).
Here is the query/action I need to run from Model1 in Model2
$sql ="update table2 SET products = $product WHERE `id` = '".$id."'";
How would I go about doing it?
If the two models are related, you can save data to two tables at the same time. See the book for information on how to use
Model::saveAll(). This is how you would represent that query though: