Answer the question
In order to leave comments, you need to log in
Yii2: Are new Query() and createCommand() signs of bad code?
Hello
, I'm still a green junior, who was given the implementation of a rather complex and fancy functionality (20 interconnected tables, a dynamic form with ~ 100 parameters, etc.), while the task was set like this, they say, "you do it, we'll see if what, let's change it."
To work with the database, there was a choice - either to do everything with objects (but given my low experience, and the number of relationships - this is hell for me), or to do everything through new Query () and createCommand () (when you need to get and write information, respectively).
The second option was chosen, on the basis that when everything is completed with all the edits, I will take time for refactoring and redo it. But, life experience tells me that when the task is done in a draft version, new "urgent things" will appear, and the code will be left like this,
In this regard, I have a question - how new Query () and createCommand () are signs of shit code? Will you have to blush when another programmer sees this code, or will it be possible to say "it's okay"?
Answer the question
In order to leave comments, you need to log in
In this regard, I have a question - how new Query () and createCommand () are signs of shit code? Will you have to blush when another programmer sees this code, or will it be possible to say "it's okay"?
If you use Yii, then use Yii goodies. ActiveRecord is not just invented there, convenient, simple.
new Query - to get data. createCommand for saving/modifying data, and for non-standard tasks
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question