\Omega\Database\QueryBuilder SqliteQueryBuilder

Mysql query builder class.

This SqliteQueryBuilder class provides methods to build and execute Sqlite queries. It extends the abstract query builder class, implementing Sqlite-specific functionality. It is designed to work with the SqliteAdapter for database connections.

Summary

Methods
Properties
Constants
__construct
all
getWhereValues
prepare
compileSelect
compileLimit
compileWheres
compileInsert
compileUpdate
compileDelete
first
take
from
select
insert
where
update
getLastInsertId
delete
No public properties found
No public constants found
No protected methods found
connection
type
columns
table
limit
offset
values
wheres
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$type

$type : string

Query type.

Type

string — Holds the query type.

$columns

$columns : string[]

Columns.

Type

array<string|int, string> — Holds an array of columns.

$table

$table : string

Table name.

Type

string — Holds the table name.

$limit

$limit : int

Limit.

Type

int — Holds the limit.

$offset

$offset : int

Offset.

Type

int — Holds the offset.

$values

$values : array

Values array.

Type

array<string|int, mixed> — Holds an array of values for the query.

$wheres

$wheres : array{: string, : string, : mixed}[]

{@inheritdoc}

Type

array<string|int, array{: string, : string, : mixed}> — Holds an array of wheres clause.

Methods

__construct()

__construct(\Omega\Database\Adapter\DatabaseAdapterInterface  $connection) : void

AbstractQueryBuilder class contructor.

Parameters

\Omega\Database\Adapter\DatabaseAdapterInterface $connection

Holds an instance of Mysql.

Returns

void —

all()

all() : array<string,mixed>[]

Fetch all rows matching the current query.

Returns

array[] —

Returns an array containing all rows in the database.

getWhereValues()

getWhereValues() : array<string,mixed>

Get the values for the where clause placeholders.

Returns

array

Return an array of result based on where clause.

prepare()

prepare() : \PdoStatement

Prepare a query against a particular connection.

Throws

\Omega\Database\Exception\QueryException

if unrecognized query type.

Returns

\PdoStatement —

Return an instance of PdoStatement.

compileSelect()

compileSelect(string  $query) : string

Add select clause to the query.

Parameters

string $query

Holds the query data.

Returns

string —

Return the compiled select clause.

compileLimit()

compileLimit(string  $query) : string

Add limit and offset clauses to the query.

Parameters

string $query

Holds the query data.

Returns

string —

Return the compiled limit clause.

compileWheres()

compileWheres(string  $query) : string

Add where clauses to the query.

Parameters

string $query

Holds the query data.

Returns

string —

Return the compiled where clause.

compileInsert()

compileInsert(string  $query) : string

Add insert clause to the query.

Parameters

string $query

Holds the query data.

Returns

string —

Return the compiled insert clause.

compileUpdate()

compileUpdate(string  $query) : string

Add update clause to the query.

Parameters

string $query

Holds the query data.

Returns

string —

Return the compiled update clause.

compileDelete()

compileDelete(string  $query) : string

Add delete clause to the query.

Parameters

string $query

Holds the query data.

Returns

string —

Return the compiled delete clause.

first()

first() : ?array<string,mixed>

Fetch the first row matching the current query.

Returns

?array

Returns an array with the first row or null if no rows are found.

take()

take(int  $limit, int  $offset) : $this

Limit a set of query results to fetch a single or a limited batch of rows.

Parameters

int $limit

The limit for the set of query results.

int $offset

The offset.

Returns

$this —

from()

from(string  $table) : $this

Indicate which table the query is targeting.

Parameters

string $table

Holds the table name.

Returns

$this —

select()

select(mixed  $columns = '*') : $this

Indicate the query type is a "select" and remember which fields should be returned by the query.

Parameters

mixed $columns

Holds the column name.

Throws

\Omega\Database\Exception\QueryException

if the columns is not a string or an arrya of string.

Returns

$this —

insert()

insert(string[]  $columns, array  $values) : int|bool

Insert a row of data into the table specified in the query and return the number of affected rows.

Parameters

string[] $columns

Holds an array of columns.

array $values

Holds an array of values.

Returns

int|bool —

Return the number of affected rows.

where()

where(string  $column, mixed  $comparator, mixed  $value = null) : $this

Store where clause data for later queries.

Parameters

string $column

Holds the column name.

mixed $comparator

Holds the column comparator.

mixed $value

Holds the data to store or null.

Returns

$this —

update()

update(string[]  $columns, array  $values) : int|bool

Insert a row of data into the table specified in the query and return the number of affected rows.

Parameters

string[] $columns

Holds an array of columns.

array $values

Holds an array of values.

Returns

int|bool —

Return the number of affected rows.

getLastInsertId()

getLastInsertId() : string|false

Get the ID of the last row that was inserted.

Returns

string|false —

Return the last insert id.

delete()

delete() : int|bool

Delete a row from the database.

Returns

int|bool —