public function testConstruct()
 {
     $field = new FieldExpression('field');
     $this->assertEquals('field', $field->getName());
     $this->assertNull($field->getTable());
     $this->assertNull($field->getAlias());
 }
 /**
  * Get the quoted name of the given field, ready to query
  * @param Field field field to get the quoted query name of
  * @param boolean useAlias true to use the field's alias if set, false otherwise (default: true)
  * @return string quoted name of the field
  */
 protected function parseFieldExpression(FieldExpression $field, $useAlias = true)
 {
     $alias = $field->getAlias();
     if ($alias && $useAlias) {
         return $this->connection->quoteIdentifier($alias);
     }
     $name = $this->connection->quoteIdentifier($field->getName());
     $table = $field->getTable();
     if ($table) {
         $name = $this->parseTableExpression($table, true) . '.' . $name;
     }
     return $name;
 }
Esempio n. 3
0
 /**
  * Processes the relations and localization of a field expression
  * @param zibo\library\database\manipulation\expression\FieldExpression $expression Field expression to process
  * @param boolean $inCondition Flag to see whether the provided expression is used in a condition or not
  * @return zibo\library\database\manipulation\expression\FieldExpression Processed expression
  */
 private function processFieldExpression(FieldExpression $expression, $inCondition = false)
 {
     $name = $expression->getName();
     $table = $expression->getTable();
     if (!$table && isset($this->fields[$name])) {
         return $this->fields[$name];
     }
     if (!$table || $table->getName() == $this->meta->getName() || $table->getName() == self::ALIAS_SELF) {
         return $this->processModelFieldExpression($name, $table, $inCondition);
     }
     return $this->processRelationFieldExpression($name, $table, $inCondition);
 }