hi guy i have problem i need get list of data when select user_id…i mean when i select user id 1 i need get all data field related with user id 1…
i attach my controll file for this
now i struck in this problem …i,m newer in yii yet give me solution
can u describe how implement control & view file for this
here is my DB & controll file
CREATE TABLE IF NOT EXISTS offer_company
(
id
int(60) NOT NULL AUTO_INCREMENT,
company_name
varchar(150) NOT NULL,
contact_detail
text NOT NULL,
User_id
int(10) NOT NULL,
created
varchar(60) NOT NULL,
modified
varchar(60) NOT NULL,
Active
varchar(25) NOT NULL,
PRIMARY KEY (id
),
KEY User_id
(User_id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ;
you can try this
$model=$this->loadModel($id, 'Offer Company');
$modelAdminUser=$this->loadModel($model->user_id, 'Users');
i need get this on index page
how implement for actionindex
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$dataProvider=new CActiveDataProvider( 'OfferDetail');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
…
index.php
<?php $this->widget(‘zii.widgets.CListView’, array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
you can write a join query and fetch the user_id redcord pass this array on dataProvider
ani
(Aneesh)
5
When you pass user_id to the controller?
The controller action like this
public function actionIndex()
{
if(isset($_GET['user_id']))
$uid=$_GET['user_id']
$criteria = new CDbCriteria();
$criteria->condition=("user_id= $uid ");
$data=new CActiveDataProvider('OfferCompany',array('criteria'=>$criteria,'pagination'=>array('pageSize'=>10)));
$this->render('index', array(
'ModelInstance' => OfferCompany::model()->findAll($criteria),
'dataProvider'=>$data
}
i modify code like this & attch in octionindex that working thank you very much
public function actionIndex()
{
$uid=Yii::app()->user->id;
if(isset($_GET['user_id']))
$uid=$_GET['user_id'];
$criteria = new CDbCriteria();
$criteria->condition=("user_id= $uid ");
$dataProvider=new CActiveDataProvider('OfferDetail',array('criteria'=>$criteria,'pagination'=>array('pageSize'=>10)));
$this->render('index', array(
'ModelInstance' => OfferCompany::model()->findAll($criteria),
'dataProvider'=>$dataProvider,
));
}