JDatabaseQueryMySQLi
Extends \JDatabaseQueryMySQLQuery Building Class.
package |
Joomla.Platform |
---|---|
subpackage |
Database |
since |
11.1 |
Methods
__call
Magic method to provide method alias support for quote() and quoteName().
__call(string $method, array $args) : string
since |
11.1 |
---|
Arguments
- $method
string
The called method.- $args
array
The array of arguments passed to the method.
Response
string
The aliased method's return value or null.
__clone
Method to provide deep copy support to nested objects and arrays when cloning.
__clone() : void
since |
11.3 |
---|
__construct
Class constructor.
__construct(\JDatabase $db = null)
__get
Magic function to get protected variable value
__get(string $name) : mixed
since |
11.1 |
---|
Arguments
- $name
string
The name of the variable.
Response
mixed
__toString
Magic function to convert the query to a string.
__toString() : string
since |
11.1 |
---|
Response
string
The completed query.
castAsChar
Casts a value to a char.
castAsChar(string $value) : string
Ensure that the value is properly quoted before passing to the method.
Usage: $query->select($query->castAsChar('a'));
since |
11.1 |
---|
Arguments
- $value
string
The value to cast as a char.
Response
string
Returns the cast value.
charLength
Gets the number of characters in a string.
charLength(string $field) : string
Note, use 'length' to find the number of bytes in a string.
Usage: $query->select($query->charLength('a'));
since |
11.1 |
---|
Arguments
- $field
string
A value.
Response
string
The required char length call.
clear
Clear data from the query or a specific clause of the query.
clear(string $clause = null) : \JDatabaseQuery
since |
11.1 |
---|
Arguments
- $clause
string
Optionally, the name of the clause to clear, or nothing to clear the whole query.
Response
\JDatabaseQuery
Returns this object to allow chaining.
columns
Adds a column, or array of column names that would be used for an INSERT INTO statement.
columns(mixed $columns) : \JDatabaseQuery
since |
11.1 |
---|
Arguments
- $columns
mixed
A column name, or array of column names.
Response
\JDatabaseQuery
Returns this object to allow chaining.
concatenate
Concatenates an array of column names or values.
concatenate(array $values, string $separator = null) : string
Usage: $query->select($query->concatenate(array('a', 'b')));
since |
11.1 |
---|
Arguments
- $values
array
An array of values to concatenate.- $separator
string
As separator to place between each value.
Response
string
The concatenated values.
currentTimestamp
Gets the current date and time.
currentTimestamp() : string
Usage: $query->where('published_up < '.$query->currentTimestamp());
since |
11.1 |
---|
Response
string
dateFormat
Returns a PHP date() function compliant date format for the database driver.
dateFormat() : 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 getDateFormat method directly.
since |
11.1 |
---|
Response
string
The format string.
delete
Add a table name to the DELETE clause of the query.
delete(string $table = null) : \JDatabaseQuery
Note that you must not mix insert, update, delete and select method calls when building a query.
Usage: $query->delete('#__a')->where('id = 1');
since |
11.1 |
---|
Arguments
- $table
string
The name of the table to delete from.
Response
\JDatabaseQuery
Returns this object to allow chaining.
dump
Creates a formatted dump of the query for debugging purposes.
dump() : string
Usage: echo $query->dump();
since |
11.3 |
---|
Response
string
escape
Method to escape a string for usage in an SQL statement.
escape(string $text, boolean $extra = false) : 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 escape method directly.
Note that 'e' is an alias for this method as it is in JDatabase.
since |
11.1 |
---|---|
throws |
|
Arguments
- $text
string
The string to be escaped.- $extra
boolean
Optional parameter to provide extra escaping.
Response
string
The escaped string.
from
Add a table to the FROM clause of the query.
from(mixed $tables) : \JDatabaseQuery
Note that while an array of tables can be provided, it is recommended you use explicit joins.
Usage: $query->select('*')->from('#__a');
since |
11.1 |
---|
Arguments
- $tables
mixed
A string or array of table names.
Response
\JDatabaseQuery
Returns this object to allow chaining.
group
Add a grouping column to the GROUP clause of the query.
group(mixed $columns) : \JDatabaseQuery
Usage: $query->group('id');
since |
11.1 |
---|
Arguments
- $columns
mixed
A string or array of ordering columns.
Response
\JDatabaseQuery
Returns this object to allow chaining.
having
A conditions to the HAVING clause of the query.
having(mixed $conditions, string $glue = 'AND') : \JDatabaseQuery
Usage: $query->group('id')->having('COUNT(id) > 5');
since |
11.1 |
---|
Arguments
- $conditions
mixed
A string or array of columns.- $glue
string
The glue by which to join the conditions. Defaults to AND.
Response
\JDatabaseQuery
Returns this object to allow chaining.
innerJoin
Add an INNER JOIN clause to the query.
innerJoin(string $condition) : \JDatabaseQuery
Usage: $query->innerJoin('b ON b.id = a.id')->innerJoin('c ON c.id = b.id');
since |
11.1 |
---|
Arguments
- $condition
string
The join condition.
Response
\JDatabaseQuery
Returns this object to allow chaining.
insert
Add a table name to the INSERT clause of the query.
insert(mixed $table, boolean $incrementField = false) : \JDatabaseQuery
Note that you must not mix insert, update, delete and select method calls when building a query.
Usage: $query->insert('#a')->set('id = 1'); $query->insert('#a)->columns('id, title')->values('1,2')->values->('3,4'); $query->insert('#__a)->columns('id, title')->values(array('1,2', '3,4'));
since |
11.1 |
---|
Arguments
- $table
mixed
The name of the table to insert data into.- $incrementField
boolean
The name of the field to auto increment.
Response
\JDatabaseQuery
Returns this object to allow chaining.
join
Add a JOIN clause to the query.
join(string $type, string $conditions) : \JDatabaseQuery
Usage: $query->join('INNER', 'b ON b.id = a.id);
since |
11.1 |
---|
Arguments
- $type
string
The type of join. This string is prepended to the JOIN keyword.- $conditions
string
A string or array of conditions.
Response
\JDatabaseQuery
Returns this object to allow chaining.
leftJoin
Add a LEFT JOIN clause to the query.
leftJoin(string $condition) : \JDatabaseQuery
Usage: $query->leftJoin('b ON b.id = a.id')->leftJoin('c ON c.id = b.id');
since |
11.1 |
---|
Arguments
- $condition
string
The join condition.
Response
\JDatabaseQuery
Returns this object to allow chaining.
length
Get the length of a string in bytes.
length(string $value) : integer
Note, use 'charLength' to find the number of characters in a string.
Usage: query->where($query->length('a').' > 3');
since |
11.1 |
---|
Arguments
- $value
string
The string to measure.
Response
integer
nullDate
Get the null or zero representation of a timestamp for the database driver.
nullDate(boolean $quoted = 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 nullDate method directly.
Usage: $query->where('modified_date <> '.$query->nullDate());
since |
11.1 |
---|
Arguments
- $quoted
boolean
Optionally wraps the null date in database quotes (true by default).
Response
string
Null or zero representation of a timestamp.
order
Add a ordering column to the ORDER clause of the query.
order(mixed $columns) : \JDatabaseQuery
Usage: $query->order('foo')->order('bar'); $query->order(array('foo','bar'));
since |
11.1 |
---|
Arguments
- $columns
mixed
A string or array of ordering columns.
Response
\JDatabaseQuery
Returns this object to allow chaining.
outerJoin
Add an OUTER JOIN clause to the query.
outerJoin(string $condition) : \JDatabaseQuery
Usage: $query->outerJoin('b ON b.id = a.id')->outerJoin('c ON c.id = b.id');
since |
11.1 |
---|
Arguments
- $condition
string
The join condition.
Response
\JDatabaseQuery
Returns this object to allow chaining.
quote
Method to quote and optionally escape a string to database requirements for insertion into the database.
quote(string $text, boolean $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 JDatabase.
Usage: $query->quote('fulltext'); $query->q('fulltext');
since |
11.1 |
---|---|
throws |
|
Arguments
- $text
string
The string to quote.- $escape
boolean
True to escape the string, false to leave it unchanged.
Response
string
The quoted input string.
quoteName
Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection risks and reserved word conflicts.
quoteName(string $name) : 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 quoteName method directly.
Note that 'qn' is an alias for this method as it is in JDatabase.
Usage: $query->quoteName('#a'); $query->qn('#a');
since |
11.1 |
---|---|
throws |
|
Arguments
- $name
string
The identifier name to wrap in quotes.
Response
string
The quote wrapped name.
rightJoin
Add a RIGHT JOIN clause to the query.
rightJoin(string $condition) : \JDatabaseQuery
Usage: $query->rightJoin('b ON b.id = a.id')->rightJoin('c ON c.id = b.id');
since |
11.1 |
---|
Arguments
- $condition
string
The join condition.
Response
\JDatabaseQuery
Returns this object to allow chaining.
select
Add a single column, or array of columns to the SELECT clause of the query.
select(mixed $columns) : \JDatabaseQuery
Note that you must not mix insert, update, delete and select method calls when building a query. The select method can, however, be called multiple times in the same query.
Usage: $query->select('a.')->select('b.id'); $query->select(array('a.', 'b.id'));
since |
11.1 |
---|
Arguments
- $columns
mixed
A string or an array of field names.
Response
\JDatabaseQuery
Returns this object to allow chaining.
set
Add a single condition string, or an array of strings to the SET clause of the query.
set(mixed $conditions, string $glue = ',') : \JDatabaseQuery
Usage: $query->set('a = 1')->set('b = 2'); $query->set(array('a = 1', 'b = 2');
since |
11.1 |
---|
Arguments
- $conditions
mixed
A string or array of string conditions.- $glue
string
The glue by which to join the condition strings. Defaults to ,. Note that the glue is set on first use and cannot be changed.
Response
\JDatabaseQuery
Returns this object to allow chaining.
union
Add a query to UNION with the current query.
union(mixed $query, boolean $distinct = false, string $glue = '') : mixed
Multiple unions each require separate statements and create an array of unions.
Usage: $query->union('SELECT name FROM #foo') $query->union('SELECT name FROM #foo','distinct') $query->union(array('SELECT name FROM #foo','SELECT name FROM #bar'))
since |
12.1 |
---|
Arguments
- $query
mixed
The JDatabaseQuery object or string to union.- $distinct
boolean
True to only return distinct rows from the union.- $glue
string
The glue by which to join the conditions.
Response
mixed
The JDatabaseQuery object on success or boolean false on failure.
unionDistinct
Add a query to UNION DISTINCT with the current query. Simply a proxy to Union with the Distinct clause.
unionDistinct(mixed $query, string $glue = '') : mixed
Usage: $query->unionDistinct('SELECT name FROM #__foo')
since |
12.1 |
---|
Arguments
- $query
mixed
The JDatabaseQuery object or string to union.- $glue
string
The glue by which to join the conditions.
Response
mixed
The JDatabaseQuery object on success or boolean false on failure.
update
Add a table name to the UPDATE clause of the query.
update(string $table) : \JDatabaseQuery
Note that you must not mix insert, update, delete and select method calls when building a query.
Usage: $query->update('#__foo')->set(...);
since |
11.1 |
---|
Arguments
- $table
string
A table to update.
Response
\JDatabaseQuery
Returns this object to allow chaining.
values
Adds a tuple, or array of tuples that would be used as values for an INSERT INTO statement.
values(string $values) : \JDatabaseQuery
Usage: $query->values('1,2,3')->values('4,5,6'); $query->values(array('1,2,3', '4,5,6'));
since |
11.1 |
---|
Arguments
- $values
string
A single tuple, or array of tuples.
Response
\JDatabaseQuery
Returns this object to allow chaining.
where
Add a single condition, or an array of conditions to the WHERE clause of the query.
where(mixed $conditions, string $glue = 'AND') : \JDatabaseQuery
Usage: $query->where('a = 1')->where('b = 2'); $query->where(array('a = 1', 'b = 2'));
since |
11.1 |
---|
Arguments
- $conditions
mixed
A string or array of where conditions.- $glue
string
The glue by which to join the conditions. Defaults to AND. Note that the glue is set on first use and cannot be changed.
Response
\JDatabaseQuery
Returns this object to allow chaining.
Properties
type
The query type.
since |
11.1 |
---|
Type(s)
string
element
The query element for a generic query (type = null).
columns
The column list for an INSERT statement.
autoIncrementField
The auto increment insert field element.
since |
11.1 |
---|
Type(s)
object