Good Practices in the Codeigniter 3 Model

Asked

Viewed 39 times

1

inserir a descrição da imagem aqui

Can anyone tell me if I work with this skeleton in the model

use a method to list and show only a given ? is correct

would like opinions as I am learning now to work with codeigniter.

  • It is not necessarily wrong/right, but the ideal is that each method (Function) had a unique responsibility, your save() does both the Sert and the update, it would be nice if they were separated, to facilitate even its maintenance

  • I understood but what would be the difficulty of maintaining in this case since the same function would be changed in only one place ? sorry I’m still learning php and good practices and would like to know in depth how it works

  • The idea is that: if you need to change the behavior/rules or validations when entering (Insert), you just need to change your Insert() method, and you don’t need to be doing multiple ifs inside save(), as your application grows the trend is that it happens, not that this will necessarily happen in this system you are working on now, but it would be ideal

  • thanks this helped to understand better, how it works

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.