Welcome Guest, Not a member yet? Register   Sign In
Escaping query

I try this query with ar
$this->db->having('distance <=',100 * 1.609344,FALSE);
        $this->db->select(" j.*, group_concat(DISTINCT et.name) as employment_types,"
                            ." group_concat(DISTINCT c.name ) as categories,"
                            ." distance(j.location_latitude, j.location_longitude, ".$latitude.", ".$longitude.") as distance"
        )->from('job j')->limit(1);
        $this->db->join('job_employment_type_relation jetr','jetr.job_id = j.id');
        $this->db->join('employment_type et','et.id=jetr.employment_type_id');
        $this->db->join('job_category_relation jcr','jcr.job_id = j.id');
        $this->db->join('category c','c.id=jcr.category_id');

and i got
SELECT `j`.*, group_concat(DISTINCT et.name) as employment_types, group_concat(DISTINCT c.name ) as categories, distance(j.location_latitude, `j`.`location_longitude`, `0`, `0)` as distance FROM (`job` j) JOIN `job_employment_type_relation` jetr ON `jetr`.`job_id` = `j`.`id` JOIN `employment_type` et ON `et`.`id`=`jetr`.`employment_type_id` JOIN `job_category_relation` jcr ON `jcr`.`job_id` = `j`.`id` JOIN `category` c ON `c`.`id`=`jcr`.`category_id` WHERE `j`.`status` = 'open' GROUP BY `j`.`id` HAVING distance <= 160.9344 LIMIT 1

see : distance(j.location_latitude, `j`.`location_longitude`, `0`, `0)`

but wen we add space before ) it parsed well

Theme © iAndrew 2016 - Forum software by © MyBB