I would like to perform a request considering one of the field is calculated (distance).
I've got something like this
$qb = $this->createQueryBuilder('p')
->andWhere('p.isPublicPlace = :classic')
->andWhere('p.titlePlace LIKE :search OR p.categoryPlace LIKE :search')
->andWhere('p.categoryPlace LIKE :categoryPlace')
This is working.
Now I will add some filter after a distance calculation
$dist = "ACOS( SIN( RADIANS(latitude))* SIN( RADIANS('.$user_lat.')) + COS( RADIANS(latitude)) * COS(RADIANS('.$user_lat.')) * COS(RADIANS(longitude) - RADIANS('.$user_lng.'))) * 6380) as distance";
$qb = $this->createQueryBuilder('p')
->select($dist)
->andWhere('p.isPublicPlace = :classic')
->andWhere('p.titlePlace LIKE :search OR p.categoryPlace LIKE :search')
->andWhere('p.categoryPlace LIKE :categoryPlace')
->having('distance' < ':maxDistance')
->orderBy('distance')
But this is not working I have an error message on the having line
(1/2) ContextErrorException Warning: get_class() expects parameter 1 to be object, boolean given
Pretty sure I'm doing all wrong but I don't know how it can be done.
Thanks for your help :)