CodeIgniter Forums

Full Version: Count selected data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]rochellecanale[/eluser]
Hey guys i just want to know how can i convert this code to active record.

Code:
$payment = 'CASH';
$sql = "SELECT COUNT(*) FROM sales WHERE payment = $payment";

El Forum

[eluser]LuckyFella73[/eluser]
Codeigniter Userguide:

Code:
$this->db->like('title', 'match'); // where(), or_where(), like(), or_like(), etc.
$this->db->from('my_table');
echo $this->db->count_all_results();

Don't forget to look at the user guide. Most the time you get your answer much faster Wink

El Forum

[eluser]rochellecanale[/eluser]
thanks you.