Active Record, Get A Single Sql-Query From A Single Table

Hi, I’m new to yii and have a simple question. I have 1 table and my the one who is log-in is sessioned I want to return all entries of the sessioned user it is determined by the userid

Here is my controller

	public function actionViewUserPost()


		$model=new ContentForm;

		$dataProvider=new CActiveDataProvider('ContentForm');


		// $record=Yii::model()->findByAttributes(array('userid' => $_POST['userid']));



		// find(array(

			// 'select'=>'title, content',

			// 'condition'=>'iduser=userid',

			// 'params'=>array(':userid'=>$_POST['ContentForm'])));

		// $dataProvider=new CActiveDataProvider('ContentForm', array(

		// 'criteria' => array(

				// 'with'=> array ()

		// )

		// )

		// $posts=ContentForm::model()->findByPk(59);

		// findAll($userid=Yii::app()->session['iduser'];,$params);






the commented parts are the one i’ve tried bud didnt work.

Here is my view:



echo "I am view user post";

$this->widget('zii.widgets.CListView', array(






<div class="view">

	<b><?php echo CHtml::encode($data->getAttributeLabel('contentid')); ?>:</b>

	<?php echo CHtml::encode($data->contentid); ?>

	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('title')); ?>:</b>

	<?php echo CHtml::encode($data->title); ?>

	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('content')); ?>:</b>

	<?php echo CHtml::encode($data->content); ?>

	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('userid')); ?>:</b>

	<?php echo CHtml::encode($data->userid); ?>

	<br />


What I am trying to do is when kim = userid 8 is logged in only the entries of kim would be shown in the view. please help

if ContentForm is model class related to user table then below code should work.


and if not then use


and then render view with $data object. This could be done without using CActiveDataProvider

$dataProvider = new CActiveDataProvider('ContentForm', array(

  'criteria' => array(

    'condition' => 'iduser = :userId',

    'params' => array(':userId' => Yii::app()->session['iduser']),