Beispiel #1
0
 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;
 }
Beispiel #2
0
 /**
  * @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();
 }
Beispiel #3
0
 /**
  * @param $identifier
  *
  * @return string
  */
 protected function quoteIdentifier($identifier)
 {
     return $this->database->quoteIdentifier($identifier);
 }