[eluser]SmokeyJoe[/eluser]
generally this looks fine to me.
Maybe you can try it this way to receive an error if it doesn't work
Code:
$this->db->select(a.*, b.*, c.*, (((acos(sin(({$lat} * pi()/180))
* sin((a.latitude * pi()/180))+cos(({$lat} * pi()/180)) * cos((a.latitude * pi()/180))
* cos((({$lng} - a.longitude)*pi()/180))))*180/pi())*60*1.1515*1.609344)
AS distance);
$this->db->from('motoboy AS a');
$this->db->join('veiculo AS b','b.motoboy_id = a.id');
$this->db->join('avaliacao AS c','c.motoboy_id = a.id');
$this->db->where('a.status',1);
$this->db->having('distance <=',$this->distance);
$this->db->order_by('distance','ASC');
$query = $this->db->get();