When the below query is run at $query->count(); it works correctly but when run as $query->limit(10); it does not
The AND is ommited from before the second WHERE on $query->limit(10);
$query->limit(10); is the simpliest thing it fails as I am actually using Pagination but that wasn't the issue.
$query = Model_Property::find()
->related('contacts')
->related('property_type')
->related('property_status')
->related('user')
->where($where_array)
->where(DB::expr($distance), '<=', floatval($position))
->order_by('address_number', 'asc');
just so you know
$distance = '(((acos(sin(('.$position["lat"].'*pi()/180)) * sin((`address_latitude`*pi()/180))+cos(('.$position["lat"].'*pi()/180))
* cos((`address_latitude`*pi()/180)) * cos((('.$position["lng"].'- `address_longitude`)*pi()/180))))*180/pi())*60*1.1515*1.609344)';