I'm using createQueryBuilder to create a query like this
$result = $qb->select('csr.id,csr.survey')
->from('Entity\ClientSurveyRecord', 'csr')
->innerJoin('Entity\AbstractClientRecord','cr','WITH','cr.id = csr.id')
->innerJoin('Entity\Client','c','WITH','cr.client = c.id')
->where('csr.survey = :id_survey')
->setParameter('id_survey',$id)
->getQuery()
->getResult();
And I get the following message Type: Doctrine\ORM\Query\QueryException
Message: [Semantical Error] line 0, col 18 near 'survey FROM Entity\ClientSurveyRecord': Error: Invalid PathExpression. Must be a StateFieldPathExpression.
Filename: /var/www/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php
But if I change $qb->select('csr.id,csr.survey')
for $qb->select('csr.id')
it works
this is the mapping file
Entity\ClientSurveyRecord:
type: entity
table: clients_survey_records
fields:
result:
type: integer
column: result
nullable: false
options:
comment: Client survey current result.
manyToOne:
survey:
targetEntity: Entity\AbstractSurvey
joinColumn:
name: id_survey
referenceColumnName: id
nullable: false
surveyShipmentTracking:
targetEntity: Entity\SurveyShipmentTracking
joinColumn:
name: id_survey_shipment_tracking
referenceColumnName: id
nullable: false
You need to join your relations using their mapped properties like for survey you need to join this in your query builder object
Also it would be good if you join
Entity\AbstractClientRecord
andEntity\Client
using some mapped properties like you have already done for survey , like