CodeIgniter 4 CRUD options & Model usage newbie guidelines

  builder, codeigniter, crud, model, php

I am a newbie wrt PHP & CodeIgniter and now getting hang of the things.

Problem Context:
I was trying to decide which option to use for my CRUDs. I thought, using the CIs Model could be best because it is provided for some reason. But ended up with many limitations, in comparison with Regular Queries or the Builder.

I read quite a bit of manuals & books, and also the forums and still have not been able to decide.

My Ask:

Please shed some expert opinion on what DB option to use for my soon-to-be-coming websites that will have front/ backends.

  1. Is the Regular Query method most versatile, Builder is in between & Models are the most restricted in CI?

  2. With my not expert level skills, what would you recommend using for all my DB operations?

  3. Or each one is better for a set of DB ops; like Model is best if we are dealing with only one table, and Builder if we have some complexity involving more than one table; and Regular queries for most complex stuff!

  4. I summed up the below wrt Models usage in CI4. Please correct / add as appropriate.

  • Each table should have one Model
  • That model should be in one separate file in (say) /App/Models (cannot place more than one
    model class in one file.)
  • Model name should match the file name
  • Namespace the model before the class definition
  • To instantiate: mention ‘use fullnamespace’ at the top of file; create it with fullpathnamespacemodelname


Source: Ask PHP