Using Model Classes Or Query Builder

I couldn’t understand something , very well.

We can use

ModelName::model()->find() , ModelName::model()->findAll(), ModelName::model()->findByPk()

etc. for reading datas from DB. Also we can insert data to DB like this :

$user = new User;

$user->name = 'Test';


I understood, all of this. And using this. But today i read, Query Builder reference. But i don’t understand, why should i use


, instead of above methods (using model classes) ?


I found a quote, i think this is answer of my question :


Your update is correct. AR makes things easier and quicker to develop. You don’t need to use DAO unless your queries are a lot complex or taking too much time or memory to run.

If you don’t need the model, use DAO. :)

In my apps, I tend to use AR and DAO half and half.

That’s another valid approach :)