Ejemplo n.º 1
0
 /**
  * Add the constraints for a relationship count query.
  *
  * @param  \Database\ORM\Builder  $query
  * @param  \Database\ORM\Builder  $parent
  * @return \Database\ORM\Builder
  */
 public function getRelationCountQuery(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $key = $this->wrap($this->getQualifiedParentKeyName());
     return $query->where($this->getHasCompareKey(), '=', new Expression($key));
 }
 /**
  * Add the constraints for a relationship count query on the same table.
  *
  * @param  \Database\ORM\Builder  $query
  * @param  \Database\ORM\Builder  $parent
  * @return \Database\ORM\Builder
  */
 public function getRelationCountQueryForSelfJoin(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $tablePrefix = $this->query->getQuery()->getConnection()->getTablePrefix();
     $query->from($this->table . ' as ' . $tablePrefix . ($hash = $this->getRelationCountHash()));
     $key = $this->wrap($this->getQualifiedParentKeyName());
     return $query->where($hash . '.' . $this->foreignKey, '=', new Expression($key));
 }
Ejemplo n.º 3
0
 /**
  * Add the constraints for a relationship count query.
  *
  * @param  \Database\ORM\Builder  $query
  * @param  \Database\ORM\Builder  $parent
  * @return \Database\ORM\Builder
  */
 public function getRelationCountQuery(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $otherKey = $this->wrap($query->getModel()->getTable() . '.' . $this->otherKey);
     return $query->where($this->getQualifiedForeignKey(), '=', new Expression($otherKey));
 }