code for counting the total no of records in a table

Hi all,

anyone plz help me to get the count of total no of records in a table

Thanks…

Hi,

You could use count method:




YourModel::model()->count();



Hi

As well

            $criteria=new CDbCriteria;


            $model = new YourModelName;


	$criteria->select='Feild Name';


	$criteria->addCondition('Condition');


	echo $model->count($criteria);

Try this








	public  function countModel($username)

	{

	    	$criteria=new CDbCriteria;

		$criteria->compare('user_name',$username,true);

		$criteria->compare('date_time',date('Y-m-d'),true);


		return $this->count($criteria); 

	      

	}












thanx for this article.