Author: Elliot Levin (elliotlevin@hotmail.com)
Inheritance: extends ProjectionSegment
Exemplo n.º 1
0
 public function visitSelect(Segments\Select $query)
 {
     $elementProjection = $query->getProjectionFunction();
     // Ensure that the return values in the format:
     // [
     //    'alias' => <expr>,
     //    ...
     // ]
     $returnExpression = $elementProjection->getReturnValueExpression();
     if (!$returnExpression instanceof O\ArrayExpression) {
         throw new PinqDemoSqlException('Cannot select non array expression');
     }
     $originalSelect = $this->compilation->sql;
     $columns = [];
     foreach ($returnExpression->getItems() as $itemExpression) {
         if (!$itemExpression->getKey() instanceof O\ValueExpression) {
             throw new PinqDemoSqlException('Select arrays cannot have variable keys');
         }
         $key = $itemExpression->getKey()->getValue();
         $columns[] = $this->compilation->expressionCompiler->compile($itemExpression->getValue(), $elementProjection) . ' AS ' . $key;
     }
     $this->compilation->sql = 'SELECT ';
     $this->compilation->sql .= implode(', ', $columns);
     $this->compilation->sql .= " FROM ({$originalSelect}) AS {$this->compilation->tableName}";
 }
Exemplo n.º 2
0
 public function visitSelect(Segments\Select $query)
 {
     $this->traversable = $this->traversable->select($this->resolvedParameters[$query->getProjectionFunction()->getCallableId()]);
 }
Exemplo n.º 3
0
 public function visitSelect(Segments\Select $query)
 {
     $this->compilation->append('Map according to: ');
     $this->compilation->appendFunction($query->getProjectionFunction());
     $this->compilation->appendLine();
 }