I am using CodeIgniter query builder. I want to add the having clause in there. My code looks as follows: (i omitted the other parts of the query):
$this->db->having($filterarray);
And i build the filterarray beforehand like this:
$filterarray = array();
if (!empty($filters['interests'])) {
$interestids = $this->interests_model->getAllIdsByDescription($filters['interests']);
$filterarray['interests IN'] = $interestids;
}
My function getAllIdsByDescription looks like this:
function getAllIdsByDescription($names){
$res = "(";
$query = $this->db->where_in('description', $names)
->select('interest_id')
->get($this->tableName);
foreach ($query->result() as $interestid) {
$res .= $interestid->interest_id;
$res .= ", ";
}
$res = substr($res, 0, -2);
$res .= ")";
return $res;
}
It translates my query to the following, hence why I have an error:
HAVING interests IN '(7)'
How do i remove the quotes around the (7) ?