Yii Framework Forum: Counting Total Data - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Counting Total Data Counting total data Rate Topic: -----

#1 User is offline   NewbieHere 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 29-November 12

Posted 06 December 2012 - 03:29 PM

Is there a way that I can count the total data that i have? example is that, I have a student table and in a student table there is a student_gender.
The thing is I want to count all the female gender that I have, and if possible i want to post it in a page thanks
0

#2 User is offline   LastDay 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 06-March 11
  • Location:Russia

Posted 06 December 2012 - 07:34 PM

You could use this - http://www.yiiframew...ributes-detail.

Example:


$countFemale = Student::model()->countByAttributes(array('student_gender' => 'female'));

echo $countFemale;



This code assumes that Student is an Active Record class for your student db table.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users