0

// SQL QUERY

SELECT*, ( ACOS( COS( RADIANS( $clat ) )* COS( RADIANS( lat ) )* COS( RADIANS( lng ) - RADIANS( $clng )) +SIN( RADIANS( $clat ) )* SIN( RADIANS( lat ) ))* 6371) AS distance_in_km FROM store_locator HAVING (distance_in_km <= $cradius) ORDER BY distance_in_km ASC LIMIT 10;

// I want to write it in this format

    $this->getSelect()->where('6371 * acos(cos( radians('.$data['lat_search'].')) * cos( radians( lat ) ) * cos( radians( lng ) - radians('.$data['long_search'].')) + sin( radians('.$data['lat_search'].') ) * sin( radians( lat ) ) ) < '.$data['radius']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.