Welcome Guest, Not a member yet? Register   Sign In
Active Record adding quotes
#1

[eluser]Unknown[/eluser]
I have in one of my queries the following:

$this->db->having('COUNT(DISTINCT tagmap.tag_id) = 3');

CI is converting it to:

HAVING COUNT(`DISTINCT` tagmap.tag_id) = `3`)

which breaks the query


Is there any way around this while still being able to use Active Record, or should I just go with the the classic query approach?

Thanks!
#2

[eluser]Seppo[/eluser]
Try this
Code:
$this->db->having('COUNT(DISTINCT tagmap.tag_id)', 3, FALSE);
#3

[eluser]mrahman[/eluser]
i searched the forum and this question is the same as mine, plus i'm using dbprefixes (i.e a prefix to prepend to tables automatically), so i cannot hardcode the tablename.field Sad

also, it would be easy to use $this->db->distinct(); and it would be no problem at all. the problem is I cannot find a function in active record that can do count(query) ...and NOT count_all(table)!!
is there one? anybody?

edit:

what i need to get is the count itself, the number of records. so here my count is not conditional but an output




Theme © iAndrew 2016 - Forum software by © MyBB