środa, 7 grudnia 2011

[Learning Yii] Find by ID - One to rule them all

Yii is fun. If you understand it. I try to understand it everyday, so I will write about it from time to time.

How to get only 1 result from any table in your project using ID?

NameOfTable::model()->search criteria->columne name
ex:
TestPack::model()->findByPk(1)->name //means: in table TestPack find row with id 1 and show it's name
Fun starts, when you need to do more complex requests - then you can chain requests:
TestPack::model()->findByPk(Test::model()->findByPk($_GET['id'])->test_pack_id)->name

Brak komentarzy:

Prześlij komentarz