Object oriented representation of multi-table query

Kadocity

New Member
Suppose we have two related tables, for example one representing a person:PERSON
  • name
  • age
  • ...
  • current_status_id
and one representing a status update at a specific time for this person:STATUS_HISTORY
  • recorded_on
  • status_id
  • blood_pressure
  • length
  • ...
I have built an application in PHP using Zend Framework, and tried to retain 'object orientedness' by using a class for representing a person and a class for representing the status of a person. I also tried to use ORM principles where possible, such as using the data mapper for separating the domain model from the data layer.What would be a nice (and object oriented) way of returning a list of persons from a data mapper, where in the list I sometimes want to know the last measured blood_pressure of the person, and sometimes not (depending on the requirements of the report/view in which the list is used). The same holds for different fields, e.g. values computed at the data layer (sum's, count's, etc.). My first thought was using a rowset (e.g. Zend_Db_Rowset) but this introduces high coupling between my view and data layer. Another way might be to return a list of persons, and then querying for each person the latest status using a data mapper for requesting the status of a specific person. However, this will result in (at least) one additional query for each person record, and does not allow me to use JOINS at the data layer.Any suggestions?
 
Back
Top