How to query with conditions

So please hope this is ok, im totally new to frameworks and the learning curve can be quite steep.

I understand what I read in the guide, I get where everything goes and how it hangs together, but try to do something I can’t see an example of, and I’m struggling.

So I have a DB with table A that has a foreign key ID to table B, which has a foreign key to table C.

I can do a SELECT query with my eyes closed, but I’m trying to use the framework and I can’t figure out how I can pull out the query results in the Yii model format.

All the relationships are set up in the database, and I used Gii to generate the scaffolding, but to do more complex searches, I have no idea.

The last question is around learning this stuff - what is the best way to come to grips with this learning curve, is it just diving in and playing ? I have the book from leanpub called “Yii 2 for beginners”, but its extremely for beginners and it doesn’t do a great job of actually explaining the concepts and where everything is - any other book recommendations on Yii2 would be great (are books on Yii 1 still valid, like The Yii Book?)

Thx

The doc should help you for searching with relations : http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#rules-with-server-names

For learning I read the Yii2 guide http://www.yiiframework.com/doc-2.0/guide-index.html or the class reference

I’m a relative newbie as well. I found the guide, http://www.yiiframework.com/doc-2.0/guide-index.html, very helpful. Also people have been very helpful on the IRC chat, http://www.yiiframework.com/chat/.

For your database question, If you have the foreign keys setup in your DB before you generate the Model with the Gii Model Generator, the generator will create methods in your Model like getB() and getC() if one or getBs() and getCs() if many. Then in your controller you can simply call from A to B to C like $a->b->c. View in docs hasOne() and hasMany() http://www.yiiframework.com/doc-2.0/yii-db-activerecord.html