Pregunta

I have a table "parkinggarages" with a foreign key "location_id". I also have a table "locations".

Table parkinggarages:
- id
- phone
- defaultlanguage
- capacity
- floors
- parkingtype

Table locations:
- id
- location
- lat
- lon

Now I want to select all the parkinggarages but I also want to select the "location" field from table "locations" with it.

How can I do this? I've tried this, but didn't work:

$result = ParkinggarageQuery::create()->joinWith('Location.location')
¿Fue útil?

Solución

$parkinggarages = ParkinggarageQuery::create()
            ->leftJoinWith('Parkinggarage.Location')
            ->find();
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top