interface IQueryBuilder (View source)

Defines an interface for a query builder that can be used to construct SQL queries.

The query builder provides a fluent API for building complex queries with features like select, join, where, order, limit, and more.

Methods

static IQueryBuilder
select(array|string ...$data)

Specifies the columns to select in the query.

static IQueryBuilder
distinct(array|string ...$data)

Specifies that the query should return distinct results.

static IQueryBuilder
from(array|string ...$data)

Specifies the table(s) to select from.

static IQueryBuilder
join(array|string ...$data)

Adds a join clause to the query.

static IQueryBuilder
selfJoin(array|string ...$data)

Adds a self join clause to the query.

static IQueryBuilder
leftJoin(array|string ...$data)

Adds a left join clause to the query.

static IQueryBuilder
rightJoin(array|string ...$data)

Adds a right join clause to the query.

static IQueryBuilder
innerJoin(array|string ...$data)

Adds an inner join clause to the query.

static IQueryBuilder
outerJoin(array|string ...$data)

Adds an outer join clause to the query.

static IQueryBuilder
crossJoin(array|string ...$data)

Adds a cross join clause to the query.

static IQueryBuilder
on(array|string ...$data)

Adds an ON clause to the current join.

static IQueryBuilder
andOn(array|string ...$data)

Adds an AND ON clause to the current join.

static IQueryBuilder
orOn(array|string ...$data)

Adds an OR ON clause to the current join.

static IQueryBuilder
where(array|string ...$data)

Adds a WHERE clause to the query.

static IQueryBuilder
andWhere(array|string ...$data)

Adds an AND WHERE clause to the query.

static IQueryBuilder
orWhere(array|string ...$data)

Adds an OR WHERE clause to the query.

static IQueryBuilder
having(array|string ...$data)

Adds a HAVING clause to the query.

static IQueryBuilder
andHaving(array|string ...$data)

Adds an AND HAVING clause to the query.

static IQueryBuilder
orHaving(array|string ...$data)

Adds an OR HAVING clause to the query.

static IQueryBuilder
group(array|string ...$data)

Adds a GROUP BY clause to the query.

static IQueryBuilder
order(array|string ...$data)

Adds an ORDER BY clause to the query.

static IQueryBuilder
orderAsc(array|string ...$data)

Adds an ORDER BY clause with ASC sorting to the query.

static IQueryBuilder
orderDesc(array|string ...$data)

Adds an ORDER BY clause with DESC sorting to the query.

static IQueryBuilder
limit(array|string ...$data)

Adds a LIMIT clause to the query.

string
build()

Builds the final SQL query string.

string
buildRaw()

Builds the final SQL query string without any modifications.

array
getValues()

Gets the values that will be bound to the query.

object
getAllMetadata()

Gets all the metadata associated with the query.

mixed
fetch(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns the result.

array|bool
fetchAll(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns all the results.

Details

static IQueryBuilder select(array|string ...$data)

Specifies the columns to select in the query.

Parameters

array|string ...$data

The columns to select.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder distinct(array|string ...$data)

Specifies that the query should return distinct results.

Parameters

array|string ...$data

The columns to select distinctly.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder from(array|string ...$data)

Specifies the table(s) to select from.

Parameters

array|string ...$data

The table(s) to select from.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder join(array|string ...$data)

Adds a join clause to the query.

Parameters

array|string ...$data

The join clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder selfJoin(array|string ...$data)

Adds a self join clause to the query.

Parameters

array|string ...$data

The self join clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder leftJoin(array|string ...$data)

Adds a left join clause to the query.

Parameters

array|string ...$data

The left join clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder rightJoin(array|string ...$data)

Adds a right join clause to the query.

Parameters

array|string ...$data

The right join clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder innerJoin(array|string ...$data)

Adds an inner join clause to the query.

Parameters

array|string ...$data

The inner join clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder outerJoin(array|string ...$data)

Adds an outer join clause to the query.

Parameters

array|string ...$data

The outer join clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder crossJoin(array|string ...$data)

Adds a cross join clause to the query.

Parameters

array|string ...$data

The cross join clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder on(array|string ...$data)

Adds an ON clause to the current join.

Parameters

array|string ...$data

The ON clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder andOn(array|string ...$data)

Adds an AND ON clause to the current join.

Parameters

array|string ...$data

The AND ON clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder orOn(array|string ...$data)

Adds an OR ON clause to the current join.

Parameters

array|string ...$data

The OR ON clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder where(array|string ...$data)

Adds a WHERE clause to the query.

Parameters

array|string ...$data

The WHERE clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder andWhere(array|string ...$data)

Adds an AND WHERE clause to the query.

Parameters

array|string ...$data

The AND WHERE clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder orWhere(array|string ...$data)

Adds an OR WHERE clause to the query.

Parameters

array|string ...$data

The OR WHERE clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder having(array|string ...$data)

Adds a HAVING clause to the query.

Parameters

array|string ...$data

The HAVING clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder andHaving(array|string ...$data)

Adds an AND HAVING clause to the query.

Parameters

array|string ...$data

The AND HAVING clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder orHaving(array|string ...$data)

Adds an OR HAVING clause to the query.

Parameters

array|string ...$data

The OR HAVING clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder group(array|string ...$data)

Adds a GROUP BY clause to the query.

Parameters

array|string ...$data

The GROUP BY clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder order(array|string ...$data)

Adds an ORDER BY clause to the query.

Parameters

array|string ...$data

The ORDER BY clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder orderAsc(array|string ...$data)

Adds an ORDER BY clause with ASC sorting to the query.

Parameters

array|string ...$data

The ORDER BY clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder orderDesc(array|string ...$data)

Adds an ORDER BY clause with DESC sorting to the query.

Parameters

array|string ...$data

The ORDER BY clause parameters.

Return Value

IQueryBuilder

The query builder instance.

static IQueryBuilder limit(array|string ...$data)

Adds a LIMIT clause to the query.

Parameters

array|string ...$data

The LIMIT clause parameters.

Return Value

IQueryBuilder

The query builder instance.

string build()

Builds the final SQL query string.

Return Value

string

The SQL query string.

string buildRaw()

Builds the final SQL query string without any modifications.

Return Value

string

The raw SQL query string.

array getValues()

Gets the values that will be bound to the query.

Return Value

array

The bound values.

object getAllMetadata()

Gets all the metadata associated with the query.

Return Value

object

The query metadata.

mixed fetch(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns the result.

Parameters

int|null $fetchStyle

The fetch style to use.

mixed $fetchArgument

The fetch argument to use.

mixed $optArgs

Additional options for the fetch operation.

Return Value

mixed

The query result.

array|bool fetchAll(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Executes the query and returns all the results.

Parameters

int|null $fetchStyle

The fetch style to use.

mixed $fetchArgument

The fetch argument to use.

mixed $optArgs

Additional options for the fetch operation.

Return Value

array|bool

The query results or false on failure.