Phalcon DB queries not working for php function inet_pton

Can someone explain why this query is not not working in phalcon framework ? it works if i run this as direct query on the db , but following

returns null as the value.

    $geo_ip = new GeoIp();

   echo $sql="  SELECT country 
                FROM `geo_ip`
              WHERE addr_type = 'ipv4'
              AND ip_start <= \"".inet_pton($this->ipCheck())."\"
              ORDER  by ip_start DESC
              LIMIT 1 ";

$geo_ip  = new \Phalcon\Mvc\Model\Resultset\Simple(null, $geo_ip , $geo_ip->getReadConnection()->query($sql));
    var_dump($geo_ip->country); 

Output :

SELECT country FROM `geo_ip` WHERE addr_type = 'ipv4' AND ip_start <= "{�<" ORDER by ip_start DESC LIMIT 1 

NULL



8.1k
edited Dec '15
<?php

 $geo_ip = new GeoIp();
$ip_chk  =  inet_pton($this->ipCheck());
 echo $sql="  SELECT country 
              FROM " . $geo_ip ."
             WHERE addr_type = 'ipv4'
             AND ip_start <= '" . $ip_chk ."'
             ORDER  by ip_start DESC
             LIMIT 1 ";

$geo_ip  = new \Phalcon\Mvc\Model\Resultset\Simple(null, $geo_ip , $geo_ip->getReadConnection()->query($sql));
  var_dump($geo_ip->country);

phalcon doesn't allow ` in phql