Reputation: 12650
How do I get a count of columns where('user_id', $id)...?
Upvotes: 1
Views: 12605
Reputation: 55946
For Row Counts
$this->db->where('user_id', $id);
$this->db->from('myTable');
$cnt = $this->db->count_all_results();
For more details please see the CodeIgniter Documentation on ActiveRecord
For Colunm Counts
$query = $this->db->where('user_id', $id)->get('myTable');
$cnt = $query->num_fields();
For more details please see the CodeIgniter Documentation on Database Query Results
Upvotes: 3