MysqlQueryBuilder
Trait for MySQL Query Building.
since |
2.0.0 |
---|---|
package |
Joomla Framework |
Methods
__toString
Magic function to convert the query to a string.
__toString() : string
since |
2.0.0 |
---|
Response
string
The 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
string
The type of string to cast as.- value
string
The value to cast as a char.- length
string
The value to cast as a char.
Response
string
SQL statement to cast the value as a char type.
concatenate
Concatenates an array of column names or values.
concatenate(string[] values, string|null separator = null) : string
since |
2.0.0 |
---|
Arguments
- values
string[]
An array of values to concatenate.- separator
string|null
As separator to place between each value.
Response
string
The concatenated values.
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
string
The value to search for.- set
string
The set of values.
Response
string
A representation of the MySQL find_in_set() function for the driver.
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
string
The expression to apply concatenation to, this may be a column name or complex SQL statement.- separator
string
The delimiter of each concatenated value
Response
string
Input values concatenated into a string, separated by delimiter
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
string
The query in string format- limit
int
The limit for the result set- offset
int
The offset for the result set
Response
string
quote
Method to quote and optionally escape a string to database requirements for insertion into the database.
quote(array|string text, bool escape = true) : string
This method is provided for use where the query object is passed to a function for modification. If you have direct access to the database object, it is recommended you use the quote method directly.
Note that 'q' is an alias for this method as it is in DatabaseDriver.
Usage: $query->quote('fulltext'); $query->q('fulltext'); $query->q(array('option', 'fulltext'));
since |
2.0.0 |
---|---|
throws |
|
Arguments
- text
array|string
A string or an array of strings to quote.- escape
bool
True (default) to escape the string, false to leave it unchanged.
Response
string
The quoted input 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
string
The regex pattern.
Response
string
selectRowNumber
Return the number of the current row.
selectRowNumber(string orderBy, string orderColumnAlias) : $this
Usage: $query->select('id'); $query->selectRowNumber('ordering,publish_up DESC', 'new_ordering'); $query->from('#__content');
since |
2.0.0 |
---|---|
throws |
|
Arguments
- orderBy
string
An expression of ordering for window function.- orderColumnAlias
string
An alias for new ordering column.
Response
$this