Ejemplo n.º 1
0
 protected function processJoins(PlatformInterface $platform, DriverInterface $driver = null, Parameters $parameters = null)
 {
     if (!$this->joins) {
         return null;
     }
     $separator = $platform->getIdentifierSeparator();
     // process joins
     $joinSpecArgArray = array();
     foreach ($this->joins as $j => $join) {
         $joinType = strtoupper($join['type']);
         $joinName = $join['name'];
         $joinAs = $joinOn = null;
         // table name
         if (is_array($joinName)) {
             $joinAs = key($joinName);
             $joinName = current($joinName);
         }
         if ($joinName instanceof TableIdentifier) {
             list($joinName, $joinSchema, $joinAs) = $joinName->getAll();
             $joinName = $platform->quoteIdentifier($joinName);
             if ($joinSchema) {
                 $joinName = $platform->quoteIdentifier($joinSchema) . $separator . $joinName;
             }
         } else {
             if ($joinName instanceof self) {
                 $joinName = '(' . $joinName->processSubSelect($joinName, $platform, $driver, $parameters) . ')';
             } else {
                 $joinName = $platform->quoteIdentifier($joinName);
             }
         }
         if ($joinAs) {
             $joinName .= ' AS ' . $platform->quoteIdentifier($joinAs);
         }
         if ($join['on'] instanceof ExpressionInterface) {
             $joinOn = $this->processExpression($join['on'], $platform, $driver, $this->processInfo['paramPrefix'] . 'join' . ($j + 1) . 'part', $parameters);
         } else {
             $joinOn = $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')', 'BETWEEN', '<', '>'));
         }
         $joinSpecArgArray[$j] = array($joinType, $joinName, $joinOn);
     }
     return array($joinSpecArgArray);
 }