active records relation

My app structure is as flows

–tabels–

image

id fileName comment date

page

id pageName comment date

content

id pageID imageID date

Is a simple app displaying images

sql query for displaying one page images is

SELECT i.* FROM image as i

INNER JOIN content as c on i.id = c.imageID

INNER JOIN page as p on i.id = c.pageID

WHERE p.pageName = ‘HMNO’

But i want to try Yii active but just don’t get it!

so far i have

class image

public function relations()


{


	// NOTE: you may need to adjust the relation name and the related


	// class name for the relations automatically generated below.


	return array(


		'content'=>array(self::BELONGS_TO, 'content', 'imageID')


	);


}

pleas help me

thanks

Could some1 explain it widh examples?

I have same problem, i know how to do it with pure sql, but i have no idea how it works with yii AR

all i need are good examples, even without comments, i can analize it my self.

So could some1 sare good examples? (all relations, 1:1, 1:n, n:n, and self related)

Did you check out this page?