Hi. I have two tables: one called Hotel and another Places. In each of them i have a field called coordinates( something like - 55.751402982902576,37.5655871629715).
Also there is a function which counts the distance between two points on earth called distanceFind($x,$y).
Now the main part: i have a form where i choose the one point(via dropdownlist) from Place table and in textfield i am pointing out the radius within which must be a hotel.
How i can list hotels whose distanceFind function between hotel coordinates and place coordinates result less than radius?
I’m not a yii wizard but If ypur functions is a php funtion I think that is the critical point:the mix of your distance function and the list of points that come from the database. The dabase functions are simple functions (averange, addition, max, etc). If you try to insert your distance function as a sql sentence is the hard way.
Why dont you just process all the points , finding the distance and build and array of the point that have a distance that you require then you can use that array.
$sql = ‘Select your points’;
$command= Yii::app()->db->createCommand($sql);
$points_array=$command->queryAll();
$points_selected=array();
foreach ($points_array as $point){
$distance=your_function($point[‘x’],$point[‘y’]);
// if the distance meets your condition add to points_selected arary.