• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
save() with multiple tables

#1
Hi! I'm new with CodeIgniter 4 (and with web frameworks in general), and while I was doing a project I've encountered a problem. I want to add an element to a DB, but I'll need to write into two different tables (one of them with a foreign key to another). Can I achieve it with $model->save() or do I have to use another method to achieve this (like a DB query with JOIN or something like that)?

Thanks in advance  Smile
Reply

#2
@yucar,

The approach that I've always have taken is update the base part of the record first then update the related table second but within the same model. Specific criteria are meet which allowed the secondary table to be updated.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.