コード例 #1
0
 public function testConstruct()
 {
     $field = new FieldExpression('field');
     $this->assertEquals('field', $field->getName());
     $this->assertNull($field->getTable());
     $this->assertNull($field->getAlias());
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * Processes the relations and localization of a model field and add the expression to the statement.
  * @param zibo\library\database\manipulation\expression\FieldExpression $fieldExpression
  * @return null
  */
 private function processAndAddFieldExpression(FieldExpression $fieldExpression)
 {
     $name = $fieldExpression->getName();
     $table = $fieldExpression->getTable();
     $alias = $fieldExpression->getAlias();
     if ($table !== null) {
         $this->addField($table, $name, null, $alias);
         return;
     }
     $field = $this->meta->getField($name);
     if ($field instanceof HasField) {
         $this->recursiveHasFields[$name] = $field;
         return;
     }
     if ($field instanceof BelongsToField) {
         $this->addBelongsTo($field);
         return;
     }
     if ($field->isLocalized()) {
         $this->addField($this->tables[self::ALIAS_SELF_LOCALIZED], $name, null, $alias);
         $this->localize = true;
     } else {
         $this->addField($this->tables[self::ALIAS_SELF], $name, null, $alias);
     }
 }