function with(array $relations, array $where = null, $order = null, $limit = 0, $offset = 0) {
		$qthis = $this->conn->quoteName($this->getName());
		$query = $this->getQueryWriter()->reset();
		$query->write("SELECT", "$qthis.*", "FROM", $qthis);
		foreach ($relations as $relation) {
			if (!($relation instanceof Table\Reference)) {
				$relation = static::resolve($relation)->getRelation($this->getName());
			}
			if ($this->getName() === $relation->foreignTable) {
				$query->write("JOIN", $relation->referencedTable)->write("ON");
				foreach ($relation as $key => $ref) {
					$query->criteria(
						array(
							"{$relation->referencedTable}.{$ref}=" => 
								new QueryExpr("{$relation->foreignTable}.{$key}")
						)
					);
				}
			} else {
				$query->write("JOIN", $relation->foreignTable)->write("ON");
				foreach ($relation as $key => $ref) {
					$query->criteria(
						array(
							"{$relation->referencedTable}.{$ref}=" => 
								new QueryExpr("{$relation->foreignTable}.{$key}")
						)
					);
				}
			}
		}
		if ($where) {
			$query->write("WHERE")->criteria($where);
		}
		if ($order) {
			$query->write("ORDER BY", $order);
		}
		if ($limit) {
			$query->write("LIMIT", $limit);
		}
		if ($offset) {
			$query->write("OFFSET", $offset);
		}
		return $this->execute($query);
	}
function with(array $relations, array $where = null, $order = null, $limit = 0, $offset = 0) {
		$qthis = $this->conn->quoteName($this->getName());
		$query = $this->getQueryWriter()->reset();
		$query->write("SELECT", "$qthis.*", "FROM", $qthis);
		foreach ($relations as $relation) {
			if (!($relation instanceof Table\Reference)) {
				$relation = static::resolve($relation)->getRelation($this->getName());
			}
			if ($this->getName() === $relation->foreignTable) {
				$query->write("JOIN", $relation->referencedTable)->write("ON");
				foreach ($relation as $key => $ref) {
					$query->criteria(
						array(
							"{$relation->referencedTable}.{$ref}=" => 
								new QueryExpr("{$relation->foreignTable}.{$key}")
						)
					);
				}
			} else {
				$query->write("JOIN", $relation->foreignTable)->write("ON");
				foreach ($relation as $key => $ref) {
					$query->criteria(
						array(
							"{$relation->referencedTable}.{$ref}=" => 
								new QueryExpr("{$relation->foreignTable}.{$key}")
						)
					);
				}
			}
		}
		if ($where) {
			$query->write("WHERE")->criteria($where);
		}
		if ($order) {
			$query->write("ORDER BY", $order);
		}
		if ($limit) {
			$query->write("LIMIT", $limit);
		}
		if ($offset) {
			$query->write("OFFSET", $offset);
		}
		return $this->execute($query);
	}
function with ( array $ relations , array $ where = null , $ order = null , $ limit = 0 , $ offset = 0 ) { $ qthis = $ this -> conn -> quoteName ( $ this -> getName ( ) ) ; $ query = $ this -> getQueryWriter ( ) -> reset ( ) ; $ query -> write ( "SELECT" , "$qthis.*" , "FROM" , $ qthis ) ; foreach ( $ relations as $ relation ) { if ( ! ( $ relation instanceof Table \ Reference ) ) { $ relation = static :: resolve ( $ relation ) -> getRelation ( $ this -> getName ( ) ) ; } if ( $ this -> getName ( ) === $ relation -> foreignTable ) { $ query -> write ( "JOIN" , $ relation -> referencedTable ) -> write ( "ON" ) ; foreach ( $ relation as $ key => $ ref ) { $ query -> criteria ( array ( "{$relation->referencedTable}.{$ref}=" => new QueryExpr ( "{$relation->foreignTable}.{$key}" ) ) ) ; } } else { $ query -> write ( "JOIN" , $ relation -> foreignTable ) -> write ( "ON" ) ; foreach ( $ relation as $ key => $ ref ) { $ query -> criteria ( array ( "{$relation->referencedTable}.{$ref}=" => new QueryExpr ( "{$relation->foreignTable}.{$key}" ) ) ) ; } } } if ( $ where ) { $ query -> write ( "WHERE" ) -> criteria ( $ where ) ; } if ( $ order ) { $ query -> write ( "ORDER BY" , $ order ) ; } if ( $ limit ) { $ query -> write ( "LIMIT" , $ limit ) ; } if ( $ offset ) { $ query -> write ( "OFFSET" , $ offset ) ; } return $ this -> execute ( $ query ) ; }
Get rows dependent on other rows by foreign keys
@param array $relations
@param array $where
@param string $order
@param int $limit
@param int $offset
@return mixed
Get rows dependent on other rows by foreign keys