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
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.
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|nullAs separator to place between each value.
Response
stringThe 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
stringThe value to search for.- set
stringThe set of values.
Response
stringA 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
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
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
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|stringA string or an array of strings to quote.- escape
boolTrue (default) to escape the string, false to leave it unchanged.
Response
stringThe 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
stringThe 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
stringAn expression of ordering for window function.- orderColumnAlias
stringAn alias for new ordering column.
Response
$this