View Data Using User Id

hi guys i have problem i have data table here this



company_id int(60) NOT NULL,

offertype_id int(60) NOT NULL,

category_id int(60) NOT NULL,

offer_title varchar(150) NOT NULL,

offer_description text NOT NULL,

image varchar(150) NOT NULL,

coupon_id varchar(60) NOT NULL,

price text NOT NULL,

unit_id varchar(60) NOT NULL,

price_now varchar(60) NOT NULL,

from varchar(80) NOT NULL,

to varchar(80) NOT NULL,[color="#FF0000"][/color]

user_id int(10) NOT NULL,

created varchar(11) NOT NULL,

modified varchar(10) NOT NULL,

Active varchar(100) NOT NULL,


KEY company_id (company_id,category_id,coupon_id,unit_id),

KEY category_id (category_id,coupon_id,unit_id),

KEY coupon_id (coupon_id),

KEY unit_id (unit_id),

KEY offertype_id (offertype_id),

KEY user_id (user_id,Active)


i have button in user profile

i attach sreen shot

when member click "see my offer" button i need to show list of offer detail which user add i need show it separate page (view)(attach sreen shot …how select user id using button & how show it please help …


HINT[/color] I’m using session for get user id when insert offer detail by user


please send me solution thank you…

you can assign some id or something with current user id like



And then just split this id in your call and get a user id then show the results on new page.

I think you are doing this work by ajax. That’s why you are getting confuse.And if you are redirecting page then i don’t think you will get any problem to show result according to Yii::app()->user->id.Since you can access Yii::app()->user->id everywhere in your application and can create some criteria and find the records.:)

So, lets try it ;)

thank codesutra can i use normal search method like advance search available in curd because in this table already have user id can i get hint about that .i confuse in search method in yii i cannot found good example yet i try various method … :(

Ahh…ok so you mean to say need a same ajax filter as we have in advance search right…?

yes …i automatically save user id(using session) when user add offer detail on web site … when he/she login their profile i need to show offer title which add by they self …when click "see my offer" i need show what offer they add.

i try to get is using advance search but not work… have any method is ti can do normal search have any method … sry about my English

how implement this for button

$offer = OfferDetail::model()->find(‘user_id=:user_id’,


$this->render(‘offer-detail-view’, array(‘model’=>$offer));

try this…

$offer = OfferDetail::model()->find("user_id=Yii::app()->user->id");

$this->render('offer-detail-view', array('offer'=>$offer));

in view offer-detail-view.php please print this


I think you need to call it through ajax.:)

Do some ajax call on Button click then…

Create one action in your controller,which you are going to call by your ajax call.


public function actionLoadOffer(){

offer = OfferDetail::model()->find("user_id=Yii::app()->user->id");

$this->renderPartial('offer-detail-view', array('offer'=>$offer),true,true);


i hope you understand what i am trying to explain here.