Welcome Guest, Not a member yet? Register   Sign In
Active record count() possible?
#1

[eluser]stef25[/eluser]
Is it possible to do something like this with CI Active Record?

$this->db->select('tag_name', count('tag_name'));

It seems the count() part is just ignored and the query only returns tag_name. From what I've found on the forums and in the documentation this is not possible?

Anyone have a workaround?
#2

[eluser]davidbehler[/eluser]
Code:
$this->db->select('tag_name');
$this->db->select("COUNT('tag_name') as my_count_var", FALSE);
#3

[eluser]stef25[/eluser]
Excellent!

As you could probably guess, this is to build a tag cloud. I found a few solutions on the forum and the rest of the web but your solution worked very well out of the box. One small issue isn't clear, I posted in the relevant thread.




Theme © iAndrew 2016 - Forum software by © MyBB