Welcome Guest, Not a member yet? Register   Sign In
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




Theme © iAndrew 2016 - Forum software by © MyBB