Model best practices question |
I'm building a REST API with four endpoints (I must say that I just started with CodeIgniter). One of them is to get data, and it receives two parameters id, and code via GET.
The issue is that the data is fetched from five different tables, all related (say table1, table2, ..., table5). Here I have a doubt about what is the right way to build the solution: Option 1: Create a model where I get the information from a SQL that joins all tables filtering on table1 where: (table1.id = id) AND (table1.code = code) AND (table1.status <> 'REJECTED') and have the controller call this model method. For example, in the controller I would have a method that contains something similar to the following: PHP Code: $dataModel = new DataModel(); PHP Code: $table1Model = new Table1Model(); The same query would be for an endpoint that needs to insert or update data in multiple tables. What would be the best option? Is there a better one that I don't realize? Any opinion/help is welcome! Regards. |
Messages In This Thread |
Model best practices question - by wolverine4277 - 07-20-2024, 03:13 PM
RE: Model best practices question - by demyr - 07-22-2024, 04:05 AM
RE: Model best practices question - by wolverine4277 - 07-22-2024, 06:16 AM
RE: Model best practices question - by ozornick - 07-22-2024, 08:59 AM
|