コード例 #1
0
 /**
  * Creates a simple JOIN to fetch the objects defined by $relation.
  *
  * Creates a simple LEFT JOIN using the aliases defined in $relation and
  * the $srcTableAlias, to fetch all objects defined by $relation, which are
  * related to the source object, fetched by $srcTableAlias.
  * 
  * @param ezcQuerySelect $q 
  * @param string $srcTableAlias 
  * @param string $dstTableAlias 
  * @param ezcPersistentRelationFindDefinition $relation 
  */
 protected function createSimpleJoin(ezcQuerySelect $q, $srcTableAlias, $dstTableAlias, ezcPersistentRelationFindDefinition $relation)
 {
     $relationDefinition = $relation->relationDefinition;
     $first = true;
     $joinCond = null;
     foreach ($relationDefinition->columnMap as $mapping) {
         $srcColumn = $this->getColumnName($srcTableAlias, $mapping->sourceColumn);
         $destColumn = $this->getColumnName($dstTableAlias, $mapping->destinationColumn);
         if ($first) {
             $joinCond = $q->expr->eq($srcColumn, $destColumn);
             $first = false;
         } else {
             $joinCond = $q->expr->and($joinCond, $q->expr->eq($srcColumn, $destColumn));
         }
     }
     $q->leftJoin($q->alias($this->db->quoteIdentifier($relationDefinition->destinationTable), $this->db->quoteIdentifier($dstTableAlias)), $joinCond);
 }