Beispiel #1
0
 /**
  * Define the built-in operators.
  */
 protected function defineBuiltInOperators()
 {
     parent::defineBuiltInOperators();
     // just override these two
     $this->setInlineOperator('and', function ($a, $b) {
         return sprintf('%s->andWhere(%s)', $a, $b);
     });
     $this->setInlineOperator('or', function ($a, $b) {
         return sprintf('%s->orWhere(%s)', $a, $b);
     });
     $this->setInlineOperator('not', function ($a) {
         return sprintf('(new \\PommProject\\Foundation\\Where("NOT(".%s->getElement() .")", %s->getValues()))', $a, $a);
     });
 }
 /**
  * {@inheritDoc}
  */
 public function visitAccess(AST\Bag\Context $element, &$handle = null, $eldnah = null)
 {
     $dimensions = $element->getDimensions();
     // simple column access
     if (count($dimensions) === 0) {
         return sprintf('%s.%s', self::ROOT_ALIAS_PLACEHOLDER, parent::visitAccess($element, $handle, $eldnah));
     }
     // this is the real column that we are trying to access
     $finalColumn = array_pop($dimensions)[1];
     // and this is a list of tables that need to be joined
     $tablesToJoin = array_map(function ($dimension) {
         return $dimension[1];
     }, $dimensions);
     $tablesToJoin = array_merge([$element->getId()], $tablesToJoin);
     $this->detectedJoins[] = $tablesToJoin;
     return sprintf('" . $this->getJoinAlias($target, "%s") . ".%s', end($tablesToJoin), $finalColumn);
 }
Beispiel #3
0
 /**
  * {@inheritDoc}
  */
 public function visitModel(AST\Model $element, &$handle = null, $eldnah = null)
 {
     $sql = parent::visitModel($element, $handle, $eldnah);
     return '"' . $sql . '"';
 }