Monday 18 August 2014

Get the count of records from a table in yii


Get the count of records from a table .
The best of way of retrieving the count of a query in yii.

For all record
$sql = "SELECT COUNT(*) FROM tablename;
$numRecordsFound = Yii::app()->db->createCommand($sql)->queryScalar();

For Criteria Based record.

$sql = "SELECT COUNT(*) FROM tablename where columnName=".$columnValue;
$numRecordsFound = Yii::app()->db->createCommand($sql)->queryScalar();

No comments:

Post a Comment

List OF BANK PAN Numbers

List OF BANK PAN Numbers Bank/Home Loan Providers PAN Number Allahabad Bank AACCA8464F Andhra Bank AABCA7375C Axis Bank...