Hi guys,
I’m newbie to Yii and this is my first time I choose any framework and start working on it based on a little OOP knowledge.
I got some how manage my application which is going on right direction but got stuck in middle of my project, my problem is here.
I got three tables.
City
-----
id
cityname
...
Post
-----
id
title
content
city_id
....
comment
-------
id
content
post_id
City Model relation
-------------------
return array(
'city' => array(self::HAS_MANY, 'Post', 'city_id'),,
);
Post Model relation
-------------------
return array(
'city' => array(self::BELONGS_TO, 'City', 'city_id'),
'comments' => array(self::HAS_MANY, 'Comment', 'post_id'),
'commentCount' => array(self::STAT, 'Comment', 'post_id'),
);
Comment Model relation
----------------------
return array(
'post' => array(self::BELONGS_TO, 'Post', 'post_id'),
);
My desired goal
From main index page a user select a City from dropdown and then it will bring up the first saved Post not all and based on that selected Post display all post related fields on index page and it will count all Comments and show that commentCount on same index page.
My DefaultController is ‘Post’ at the moment, should I change it to ‘City’.
Please guide me into this my first application, I’ll highly appreciate all you guys help.
Saad