Welcome Guest, Not a member yet? Register   Sign In
Error Number: 1054 / 1064 -> quoting numeric values
#1

[eluser]cattox[/eluser]
Hi all,

I'm trying to build an sql query with CI RA.

the query follows the pattern:

$this->db->select('x,y,count(z)');
$this->db->from('table');
$this->db->group_by('x');
$this->db->having('count(z) >=' .$var); // $var contains a numeric value
...

If I execute this code i get an sql expression with the $var numeric value surrounded by single quotes and in consequence of that, error 1054.
If I change the comparing operator order like this:

$this->db->having('count(z) =>' .$var)

I get error 1064.

The thing is: why CI surrounds the numeric value with quotes? Am I doing something wrong? If no, is there any work around?

thanks in advance




Theme © iAndrew 2016 - Forum software by © MyBB