Answer the question
In order to leave comments, you need to log in
Do you need a model in yii2 in this case?
They gave a test task for yii2. So far, everything seems to be clear, since I studied Laravel before. But I don't want to use Active Record, for example. It seems to me that it is easier to write native SQL queries using PDO. It turns out that in this case I do not need a model? And can they not hire me if I say that it is more convenient for me through SQL queries, since Active Record can get confused?
Answer the question
In order to leave comments, you need to log in
I don’t think that you will be hired as a Yii2 programmer if you use your own classes with direct requests via PDO everywhere instead of native AR models (why?).
It's like replacing the computerized steering wheel on an F-1 with a ship's steering wheel and waiting to be allowed to compete.
If you refuse AR and models, then you will either validate the data yourself or not at all. Plus, I don't quite understand how you can get confused in AR. One object - one line in the table.
If someone told me at the interview that they would work through PDO, they would immediately go further in search of a job.
It turns out that in this case I do not need a model?
Let me explain popularly:
For normal use - AR is enough, if you need to make complex selections or you start clearing your models, you can always go down below and file your query through DAO (this is also PDO, but with a more convenient interface)
In order not to spoil, I suggest read manuals from Yii2 team:
I want to note that Active Record is considered the easiest to learn, in fact, in the world of web development, Active Record and Data Mapper (Doctrine) rule the ball (not counting pure queries) ... it’s worth exploring and feeling both options for 2-3 days each and to understand what, where and how... this will give you bonuses, in Yii2, in fact, AR cannot be separated from the project...
Active Record is used in Ruby on Rails (from there he came to the PHP world), used in Yii2 and Laravel (Eloquent on this pattern), Data Mapper is mainly used in the world of Symfony and again Laravel The
ability to make clean queries is valued much more than the ability to work with AR - so feel free to go to work or do them in a test ... an adequate team lead will check it out.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question