Doctrine2 - relationship
Posted
by
Filip Golonka
on Stack Overflow
See other posts from Stack Overflow
or by Filip Golonka
Published on 2012-11-23T16:53:48Z
Indexed on
2012/11/24
17:04 UTC
Read the original article
Hit count: 251
I'm developing an application, which is looking for optimal route and timetable in public transport. I have some experience about Doctrine1, but it's my first time with Doctrine2. There is soem new fields to describe relations (mappedBy and inversedBy) and also some new ways of mapping.
I have following code:
$query = $this->em->createQuery("SELECT partial cls.{stop}, partial t.{arriveTime, departureTime} FROM \Entities\Timetable t
JOIN t.ride r
JOIN t.carrierLineStop cls
WHERE t.departureTime>=:time AND
r.idCarrierLine=:carrierLine AND
(cls.idStop=:firstStop OR cls.idStop=:lastStop)");
$query->setParameters(array(
'time' => $time,
'carrierLine' => $path->getLine(),
'firstStop' => $path->getFirstStop(),
'lastStop' => $path->getLastStop()
));
When I try to execute that script I've got an error:
[Semantical Error] line 0, col 24 near '}, partial t.{arriveTime,': Error: There is no mapped field named 'stop' on class Entities\CarrierLineStop.
Mapping files:
Entities\CarrierLineStop:
type: entity
table: carrier_line_stop
fields:
idCarrierLineStop:
id: true
type: integer
unsigned: false
nullable: false
column: id_carrier_line_stop
generator:
strategy: IDENTITY
nextStop:
type: integer
unsigned: false
nullable: true
column: next_stop
manyToOne:
idCarrierLine:
targetEntity: Entities\CarrierLine
cascade: { }
mappedBy: null
inversedBy: null
joinColumns:
id_carrier_line:
referencedColumnName: id_carrier_line
orphanRemoval: false
stop:
column: id_stop
targetEntity: Entities\Stop
cascade: { }
mappedBy: null
inversedBy: carrierLineStop
joinColumns:
id_stop:
referencedColumnName: id_stop
orphanRemoval: false
lifecycleCallbacks: { }
-
Entities\Stop:
type: entity
table: stop
fields:
idStop:
id: true
type: integer
unsigned: false
nullable: false
column: id_stop
generator:
strategy: IDENTITY
name:
type: string
length: 45
fixed: false
nullable: true
miejscowosc:
type: string
length: 45
fixed: false
nullable: true
latitude:
type: decimal
nullable: true
longitude:
type: decimal
nullable: true
oneToMany:
carrierLineStop:
targetEntity: Entities\CarrierLineStop
cascade: { }
mappedBy: stop
inversedBy: null
joinColumns:
id_stop:
referencedColumnName: id_stop
orphanRemoval: false
lifecycleCallbacks: { }
I have no idea about where the problem is...
© Stack Overflow or respective owner