I try to execute this:
SELECT user.id, user.name, user_profile.home_location_id, user_profile.current_location_id,
locations.id, (
6371 * acos (
cos ( radians(:lat:) )
* cos( radians( locations.latitude ) )
* cos( radians( locations.longitude ) - radians(:lon:) )
+ sin ( radians(:lat:) )
* sin( radians( locations.latitude ) )
)
) AS distance
FROM
Phalcon\UserPlugin\Models\User\UserProfile user_profile
JOIN ( Phalcon\UserPlugin\Models\User\User user, Phalcon\UserPlugin\Models\Location\Locations locations )
ON (user_profile.home_location_id != '' and locations.id = user_profile.home_location_id and user.id = user_profile.user_id)
HAVING distance < 25
ORDER BY distance
LIMIT 0 , 20
And i get this error:
Phalcon\Mvc\Model\Exception: Syntax error, unexpected token (, near to 'Phalcon\UserPlugin\Models\User\User user
Any help, please ? @Phalcon ?