CodeIgniter, models, and ORM, how to deal with this?

后端 未结 10 835
谎友^
谎友^ 2021-02-03 19:11

I\'m starting with CodeIgniter and after several hours diving in Google I\'m a bit confused.

Let\'s try to explain my question with a easy example: I have a table \'car

10条回答
  •  既然无缘
    2021-02-03 20:00

    What you want to do is create a library that extends the ActiveRecord class. Some people are ahead of you:

    http://codeigniter.com/wiki/ActiveRecord_Class/

    good mods in the thread, here:

    http://codeigniter.com/forums/viewthread/101987/

    If you're looking for ORM methods that are general to your app, just extend the ActiveRecord class. For my application, knowing the structure of a table allows me to scaffold (auto-generate) forms, and do other mapping. I do API-to-API mapping, so I include a GetStructure() method in MyActiveRecord and build other things from there.

    (RoR snickering can bugger off now)

    Edit: while I am a fan of the scope and power of Doctrine, I think it's demand for command-line usage places it beyond the spirit of CI. What's right for you is what's right for you, but if I'm going to use Doctrine, I might as well use Symfony, right? Or RoR, for that matter, right?? See where I'm gong with this? Right tool for the right time.

提交回复
热议问题