How do I get a count of columns where('user_id', $id)...?
A:
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
Aren
2010-05-07 22:01:37
Doesn't this count rows?
Kevin Brown
2010-05-07 22:02:08
Oh you're right... bonk on my head for not reading the question! Updated with column counts.
Aren
2010-05-07 22:11:05