public function toString() { $string = $this->type . ' ' . $this->database->quoteIdentifier($this->table) . ' '; if ($this->alias) { $string .= 'AS ' . $this->database->quoteIdentifier($this->alias) . ' '; } $string .= $this->relation . ' (' . $this->condition . ')'; return $string; }
/** * @param null|DatabaseQuery $inputQuery * * @return DatabaseResult|null * @throws QueryBuilderException */ public function getRows($inputQuery = null) { $query = $this->database->createQuery(); foreach ($this->getSingleParentRelations() as $relation) { $key = strstr($relation->getRelatedKey(), '.') ? $relation->getRelatedKey() : $this->table . '.' . $relation->getRelatedKey(); $foreignKey = strstr($relation->getKey(), '.') ? $relation->getKey() : $relation->getRelatedTable() . '.' . $relation->getKey(); $query->leftJoin($relation->getRelatedTable(), $this->database->createCondition()->equal($key, $this->database->quoteIdentifier($foreignKey)))->fields(array($relation->getRelatedTable() . '.*')); } $query->select()->from($this->table)->fields(array($this->table . '.*')); $query->setEntity($this->entityRule); if (!is_null($inputQuery)) { $query->composeWith($inputQuery); } return $query->execute(); }
/** * @param $identifier * * @return string */ protected function quoteIdentifier($identifier) { return $this->database->quoteIdentifier($identifier); }