PostgresqlQueryBuilder

Trait for PostgreSQL Query Building.

since

2.0.0

package

Joomla Framework

Methods

__toString

Magic function to convert the query to a string, only for PostgreSQL specific queries

__toString() : string
since

2.0.0

Response

stringThe completed query.

castAs

Casts a value to a char.

castAs(string type, string value, string length = null) : string

Ensure that the value is properly quoted before passing to the method.

Usage: $query->select($query->castAs('CHAR', 'a'));

since

1.0

Arguments

type

stringThe type of string to cast as.

value

stringThe value to cast as a char.

length

stringThe value to cast as a char.

Response

stringSQL statement to cast the value as a char type.

clear

Clear data from the query or a specific clause of the query.

clear(string clause = null) : $this
since

2.0.0

Arguments

clause

stringOptionally, the name of the clause to clear, or nothing to clear the whole query.

Response

$this

concatenate

Concatenates an array of column names or values.

concatenate(string[] values, string|null separator = null) : string

Usage: $query->select($query->concatenate(array('a', 'b')));

since

2.0.0

Arguments

values

string[]An array of values to concatenate.

separator

string|nullAs separator to place between each value.

Response

stringThe concatenated values.

currentTimestamp

Gets the current date and time.

currentTimestamp() : string
since

2.0.0

Response

stringReturn string used in query to obtain

dateAdd

Add to the current date and time.

dateAdd(string date, string interval, string datePart) : string

Usage: $query->select($query->dateAdd());

Prefixing the interval with a - (negative sign) will cause subtraction to be used.

since

2.0.0

link

Arguments

date

stringThe db quoted string representation of the date to add to

interval

stringThe string representation of the appropriate number of units

datePart

stringThe part of the date to perform the addition on

Response

stringThe string with the appropriate sql for addition of dates

day

Used to get a string to extract day from date column.

day(string date) : string

Usage: $query->select($query->day($query->quoteName('dateColumn')));

since

2.0.0

Arguments

date

stringDate column containing day to be extracted.

Response

stringReturns string to extract day from a date.

findInSet

Find a value in a varchar used like a set.

findInSet(string value, string set) : string

Ensure that the value is an integer before passing to the method.

Usage: $query->findInSet((int) $parent->id, 'a.assigned_cat_ids')

since

2.0.0

Arguments

value

stringThe value to search for.

set

stringThe set of values.

Response

stringA representation of the MySQL find_in_set() function for the driver.

forShare

Sets the FOR SHARE lock on select's output row

forShare(string tableName, string glue = ',') : $this
since

2.0.0

Arguments

tableName

stringThe table to lock

glue

stringThe glue by which to join the conditions. Defaults to ',' .

Response

$this

forUpdate

Sets the FOR UPDATE lock on select's output row

forUpdate(string tableName, string glue = ',') : $this
since

2.0.0

Arguments

tableName

stringThe table to lock

glue

stringThe glue by which to join the conditions. Defaults to ',' .

Response

$this

groupConcat

Aggregate function to get input values concatenated into a string, separated by delimiter

groupConcat(string expression, string separator = ',') : string

Usage: $query->groupConcat('id', ',');

since

2.0.0

Arguments

expression

stringThe expression to apply concatenation to, this may be a column name or complex SQL statement.

separator

stringThe delimiter of each concatenated value

Response

stringInput values concatenated into a string, separated by delimiter

hour

Used to get a string to extract hour from date column.

hour(string date) : string

Usage: $query->select($query->hour($query->quoteName('dateColumn')));

since

2.0.0

Arguments

date

stringDate column containing hour to be extracted.

Response

stringReturns string to extract hour from a date.

limit

Set the LIMIT clause to the query

limit(int limit) : $this
since

2.0.0

Arguments

limit

intNumber of rows to return

Response

$this

minute

Used to get a string to extract minute from date column.

minute(string date) : string

Usage: $query->select($query->minute($query->quoteName('dateColumn')));

since

2.0.0

Arguments

date

stringDate column containing minute to be extracted.

Response

stringReturns string to extract minute from a date.

month

Used to get a string to extract month from date column.

month(string date) : string

Usage: $query->select($query->month($query->quoteName('dateColumn')));

since

2.0.0

Arguments

date

stringDate column containing month to be extracted.

Response

stringReturns string to extract month from a date.

noWait

Sets the NOWAIT lock on select's output row

noWait() : $this
since

2.0.0

Response

$this

offset

Set the OFFSET clause to the query

offset(int offset) : $this
since

2.0.0

Arguments

offset

intAn integer for skipping rows

Response

$this

processLimit

Method to modify a query already in string format with the needed additions to make the query limited to a particular number of results, or start at a particular offset.

processLimit(string query, int limit, int offset) : string
since

2.0.0

Arguments

query

stringThe query in string format

limit

intThe limit for the result set

offset

intThe offset for the result set

Response

string

rand

Get the function to return a random floating-point value

rand() : string

Usage: $query->rand();

since

2.0.0

Response

string

regexp

Get the regular expression operator

regexp(string value) : string

Usage: $query->where('field ' . $query->regexp($search));

since

2.0.0

Arguments

value

stringThe regex pattern.

Response

string

returning

Add the RETURNING element to INSERT INTO statement.

returning(mixed pkCol) : $this
since

2.0.0

Arguments

pkCol

mixedThe name of the primary key column.

Response

$this

second

Used to get a string to extract seconds from date column.

second(string date) : string

Usage: $query->select($query->second($query->quoteName('dateColumn')));

since

2.0.0

Arguments

date

stringDate column containing second to be extracted.

Response

stringReturns string to extract second from a date.

year

Used to get a string to extract year from date column.

year(string date) : string

Usage: $query->select($query->year($query->quoteName('dateColumn')));

since

2.0.0

Arguments

date

stringDate column containing year to be extracted.

Response

stringReturns string to extract year from a date.

Properties

forUpdate

The FOR UPDATE element used in "FOR UPDATE" lock

since

2.0.0

Type(s)

\Joomla\Database\Query\QueryElement

forShare

The FOR SHARE element used in "FOR SHARE" lock

since

2.0.0

Type(s)

\Joomla\Database\Query\QueryElement

noWait

The NOWAIT element used in "FOR SHARE" and "FOR UPDATE" lock

since

2.0.0

Type(s)

\Joomla\Database\Query\QueryElement

limit

The LIMIT element

since

2.0.0

Type(s)

\Joomla\Database\Query\QueryElement

offset

The OFFSET element

since

2.0.0

Type(s)

\Joomla\Database\Query\QueryElement

returning

The RETURNING element of INSERT INTO

since

2.0.0

Type(s)

\Joomla\Database\Query\QueryElement