Hello,

Im using the geocode behaviour from 
http://bakery.cakephp.org/articles/view/geocoding-in-cakephp

findAllByDistance(........
.......
$model->find('all',array('conditions'=>"(3958 * 3.1415926 *
SQRT(({$y2} - {$y}) * ({$y2} - {$y}) + COS({$y2} / 57.29578) *
COS({$y} / 57.29578) * ({$x2} - {$x}) * ({$x2} - {$x})) / 180) <=
{$distance}"));
.....

Works fine, but would like to add virtual 'distance' into the query so
results can be sorted by shortest distance

I think this is could be done with MySQL HAVING statement ?

maybe similar too:

SELECT id, ( 3959 * acos( cos( radians(blahblah) ) *
cos( radians( lat ) ) * cos( radians( lng ) - radians(blahblah) ) +
sin( radians(blah) ) *sin( radians( lat ) ) ) ) AS distance FROM
markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;


Thanks for any help!!!

Andras

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to