Author: Elliot Levin (elliotlevin@hotmail.com)
Inheritance: extends ProjectionSegment
コード例 #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}";
 }
コード例 #2
0
ファイル: ScopeEvaluator.php プロジェクト: timetoogo/pinq
 public function visitSelect(Segments\Select $query)
 {
     $this->traversable = $this->traversable->select($this->resolvedParameters[$query->getProjectionFunction()->getCallableId()]);
 }
コード例 #3
0
ファイル: ScopeCompiler.php プロジェクト: timetoogo/pinq
 public function visitSelect(Segments\Select $query)
 {
     $this->compilation->append('Map according to: ');
     $this->compilation->appendFunction($query->getProjectionFunction());
     $this->compilation->appendLine();
 }