开发者

Codeigniter: Count columns with value for user

开发者 https://www.devze.com 2022-12-29 07:33 出处:网络
开发者_StackOverflow中文版How do I get a count of columns where(\'user_id\', $id)...?For Row Counts

开发者_StackOverflow中文版How do I get a count of columns where('user_id', $id)...?


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

Here

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

Here

0

精彩评论

暂无评论...
验证码 换一张
取 消