w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Nearest distance algorithm using Phalcon model manager

Semicolon in your PHQL query causes Scanning error before ... problem. Just remove it and query should be ok:

$query_text = "SELECT 
                 id, 
                 ( 3959 * acos( cos( radians(:locationlat:) ) * cos (
radians( locationlat ) ) * cos( radians( locationlng ) -
radians(:locationlng:) ) + sin( radians(:locationlat:) ) * sin( radians(
locationlat ) ) ) ) AS distance 
               FROM 
                 Listing
               HAVING 
                 distance < 25";
                             ^^

$query = $this->modelsManager->createQuery($query_text);

$listing = $query->execute(array(
    'locationlat' => '1.313022',
    'locationlng' => '1.313022',              
));




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.