H
H
HellWalk2017-10-12 11:56:44
Yii
HellWalk, 2017-10-12 11:56:44

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

2 answer(s)
M
Maxim Fedorov, 2017-10-12
@HellWalk

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"?

The application is not considered shit code if it is really justified, whether it is justified in your project is known only to you.
You don't need to refactor the entire application, you need to refactor in small pieces as you work on other tasks. So to say, make the code with which you work a little cleaner than it was

A
Alexander Urich, 2017-10-13
@Urichalex

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 question

Ask a Question

731 491 924 answers to any question