CodeIgniter Forums
ORM or SQL? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: ORM or SQL? (/showthread.php?tid=81559)



ORM or SQL? - frocco - 03-17-2022

Hello,
What is the best practice for db work by most developers?
Them orm must have more overhead dealing with models and entities.
Is it better to just use sql?

if so, do most of you use sql in controller or create a library?
I guess you could even have one model class and pass the sql and table name in.


RE: ORM or SQL? - ignitedcms - 03-17-2022

Personally, I don't do ORM's but I can see their appeal, I'm happy with just the query builders. Ultimately it is up to you and your needs.


RE: ORM or SQL? - iRedds - 03-17-2022

Controllers, models,... for what?
Write everything in one file and layout and query to the database.


RE: ORM or SQL? - frocco - 03-17-2022

(03-17-2022, 06:57 AM)iRedds Wrote: Controllers, models,... for what?
Write everything in one file and layout and query to the database.

I do not understand your suggestion.
Can you explain?

(03-17-2022, 06:55 AM)ignitedcms Wrote: Personally, I don't do ORM's but I can see their appeal, I'm happy with just the query builders. Ultimately it is up to you and your needs.

Where do you put your query builder logic?
In controller?


RE: ORM or SQL? - ignitedcms - 03-17-2022

No I typically put my query builder logic in models, but if I understood correctly was the question regarding the pros and cons of using a ORM?


RE: ORM or SQL? - frocco - 03-17-2022

(03-17-2022, 07:14 AM)ignitedcms Wrote: No I typically put my query builder logic in models, but if I understood correctly was the question regarding the pros and cons of using a ORM?

ok, thank you


RE: ORM or SQL? - InsiteFX - 03-18-2022

If you have a lot of business logic that needs multiple models then create a library and load the models in it.


RE: ORM or SQL? - frocco - 03-19-2022

(03-18-2022, 12:03 AM)InsiteFX Wrote: If you have a lot of business logic that needs multiple models then create a library and load the models in it.

Thank you