Esempio n. 1
0
 /**
  * This method instantites the Purchase object and its associated document object from values 
  * returned from an SQL SELECT JOIN statement.
  * 
  * Method does not affect state and can be made static.
  * 
  * @param array $aData
  * @return Purchase
  */
 private static function build(array $aData)
 {
     $oDocument = new Document();
     $oDocument->exchangeArray($aData);
     //Review, appended table purchase name name to returned columns in the join
     //to avoid ambiguous column name.
     //Reassigning to expected key names for hydrating the Purchase object.
     $aData[Purchase::ID] = $aData['purchase.' . Purchase::ID];
     $aData[Purchase::CREATED_ON] = $aData['purchase.' . Purchase::CREATED_ON];
     $aData[Purchase::EMAIL] = $aData['purchase.' . Purchase::EMAIL];
     $oPurchase = new Purchase();
     $oPurchase->exchangeArray($aData);
     $oPurchase->setDocument($oDocument);
     return $oPurchase;
 }