Model files in CI4 |
(07-19-2021, 10:57 AM)Filippo65 Wrote: 1) I'm already grouping many tabel's data into big multi-table objects, i.e: I would do it with your 1B solution. This is how I did it in my tutorial. Simple models and entities for recipes and ingredients, and the library build the final object containing one recipe with all its ingredients. But you can also do it in the model if that's what you prefer. It's really is a personal choice on how you want to organize your code. Personally I prefer my models to be simple and to do selects in a single table. (07-19-2021, 10:57 AM)Filippo65 Wrote: 2) $GC is declared "static" in the Controller. So I can handle it with the librarie's functions. What is $GC and why does it need to be static? (07-19-2021, 10:57 AM)Filippo65 Wrote: 3) In each library I had this header: There's no longer a CI super-object in CI4. You can use service('.....') to get a reference to the shared instance of the object you need. For example, if your need the request object in a library: PHP Code: use CodeIgniter\HTTP\IncomingRequest; Note that the request object is already available in the controller with $this->request. (07-19-2021, 10:57 AM)Filippo65 Wrote: 4) In CI4 standard Model there is a Key declaration: This is to define the primary key. Not the foreign keys. If you have a table where the primary key is a combination of several columns, I would advise to change that to use a single column with an auto-increment id. If you can't do this, you won't be able to use some functions from the Model class because it needs a single column for the primary key. But if your other column are just reference to other tables, it won't cause any problem. |
Messages In This Thread |
Model files in CI4 - by Filippo65 - 07-06-2021, 10:39 AM
RE: Model files in CI4 - by MGatner - 07-07-2021, 06:14 AM
RE: Model files in CI4 - by paliz - 07-07-2021, 09:17 AM
RE: Model files in CI4 - by Filippo65 - 07-12-2021, 10:06 AM
RE: Model files in CI4 - by includebeer - 07-12-2021, 03:44 PM
RE: Model files in CI4 - by InsiteFX - 07-12-2021, 09:04 PM
RE: Model files in CI4 - by davis.lasis - 07-13-2021, 03:29 AM
RE: Model files in CI4 - by Filippo65 - 07-14-2021, 11:18 AM
RE: Model files in CI4 - by includebeer - 07-14-2021, 02:23 PM
RE: Model files in CI4 - by Filippo65 - 07-19-2021, 10:57 AM
RE: Model files in CI4 - by includebeer - 07-19-2021, 02:45 PM
RE: Model files in CI4 - by Filippo65 - 07-20-2021, 10:52 AM
RE: Model files in CI4 - by Filippo65 - 07-20-2021, 12:47 PM
RE: Model files in CI4 - by Filippo65 - 07-21-2021, 10:30 AM
RE: Model files in CI4 - by includebeer - 07-23-2021, 04:52 AM
Model files in CI4 - by Filippo65 - 08-20-2021, 09:28 AM
RE: Model files in CI4 - by ikesela - 08-20-2021, 12:50 PM
RE: Model files in CI4 - by includebeer - 09-05-2021, 03:39 PM
RE: Model files in CI4 - by Filippo65 - 09-23-2021, 07:44 AM
RE: Model files in CI4 - by InsiteFX - 09-06-2021, 12:56 AM
RE: Model files in CI4 - by Filippo65 - 09-25-2021, 09:34 AM
RE: Model files in CI4 - by InsiteFX - 09-26-2021, 12:43 AM
|