residentSector:
columns:
id_resident_sector:
type: integer
primary: true
autoincrement: true
id_resident:
type: integer(8)
id:
type: integer(8)
date:
type: timestamp
residents:
columns:
id_resident:
type: integer(8)
primary: true
autoincrement: true
firstname:
type: string(50)
lastname:
type: string(50)
relations:
Sectors:
class: Sectors
local: id_resident
foreign: id
refClass: residentSector
Sectors:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
sector_name:
type: string(50)
id_resp:
type: integer(4)
visibility:
type: integer(1)
I want to select all the "residents" of a given "sector" at à given date (the lastest date as example).
My problem is the date field is in the refclass (because it's the date of assignation) so
->where('residents.Sectors.date =max(residents.Sectors.date) ')
won't work obviously because the refclass is not part of the collection ..
what is the good way to define the doctrine relation so i can get the latest sector in date of a resident ?
Thanks in advance !