Joomla CMS
4.2.2
Documentation des API du CMS Joomla en version 4.2.2
|
Fonctions membres publiques | |
__toString () | |
call ($columns) | |
castAs (string $type, string $value, ?string $length=null) | |
charLength ($field, $operator=null, $condition=null) | |
clear ($clause=null) | |
columns ($columns) | |
concatenate ($values, $separator=null) | |
currentTimestamp () | |
delete ($table=null) | |
exec ($columns) | |
findInSet ($value, $set) | |
from ($table) | |
alias ($alias) | |
year ($date) | |
month ($date) | |
day ($date) | |
hour ($date) | |
minute ($date) | |
second ($date) | |
group ($columns) | |
groupConcat ($expression, $separator=',') | |
having ($conditions, $glue='AND') | |
insert ($table, $incrementField=false) | |
join ($type, $table, $condition=null) | |
length ($value) | |
nullDate ($quoted=true) | |
isNullDatetime ($column) | |
order ($columns) | |
rand () | |
regexp ($value) | |
select ($columns) | |
selectRowNumber ($orderBy, $orderColumnAlias) | |
set ($conditions, $glue=',') | |
update ($table) | |
values ($values) | |
where ($conditions, $glue='AND') | |
whereIn (string $keyName, array $keyValues, $dataType=ParameterType::INTEGER) | |
whereNotIn (string $keyName, array $keyValues, $dataType=ParameterType::INTEGER) | |
extendWhere ($outerGlue, $conditions, $innerGlue='AND') | |
bindArray (array $values, $dataType=ParameterType::INTEGER) | |
union ($query, $distinct=true) | |
unionAll ($query) | |
querySet ($query) | |
toQuerySet () | |
Fonctions membres publiques hérités de PreparableInterface | |
bind ($key, &$value, $dataType=ParameterType::STRING, $length=0, $driverOptions=[]) | |
unbind ($key) | |
& | getBounded ($key=null) |
Fonctions membres publiques hérités de LimitableInterface | |
processLimit ($query, $limit, $offset=0) | |
setLimit ($limit=0, $offset=0) | |
__toString | ( | ) |
Convert the query object to a string.
Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.
alias | ( | $alias | ) |
Add alias for current query.
Usage: $query->select('*')->from('#__a')->alias('subquery');
string | $alias | Alias used for a JDatabaseQuery. |
Implémenté dans DatabaseQuery.
bindArray | ( | array | $values, |
$dataType = ParameterType::INTEGER |
|||
) |
Binds an array of values and returns an array of prepared parameter names.
Note that all values must be the same data type.
Usage: $query->whereIn('column in (' . implode(',', $query->bindArray($keyValues, $dataType)) . ')');
array | $values | Values to bind |
array | string | $dataType | Constant corresponding to a SQL datatype. It can be an array, in this case it has to be same length of $key |
Implémenté dans DatabaseQuery.
call | ( | $columns | ) |
Add a single column, or array of columns to the CALL clause of the query.
Usage: $query->call('a.*')->call('b.id'); $query->call(array('a.*', 'b.id'));
array | string | $columns | A string or an array of field names. |
QueryTypeAlreadyDefinedException | if the query type has already been defined |
Implémenté dans DatabaseQuery.
castAs | ( | string | $type, |
string | $value, | ||
?string | $length = null |
||
) |
Casts a value to a specified type.
Ensure that the value is properly quoted before passing to the method.
Usage: $query->select($query->castAs('CHAR', 'a'));
string | $type | The type of string to cast as. |
string | $value | The value to cast as a char. |
string | $length | Optionally specify the length of the field (if the type supports it otherwise ignored). |
UnknownTypeException | When unsupported cast for a database driver |
Implémenté dans DatabaseQuery, et SqlsrvQuery.
Gets the number of characters in a string.
Note, use 'length' to find the number of bytes in a string.
Usage: $query->select($query->charLength('a'));
string | $field | A value. |
string | null | $operator | Comparison operator between charLength integer value and $condition |
string | null | $condition | Integer value to compare charLength with. |
Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.
clear | ( | $clause = null | ) |
Clear data from the query or a specific clause of the query.
string | $clause | Optionally, the name of the clause to clear, or nothing to clear the whole query. |
Implémenté dans DatabaseQuery.
columns | ( | $columns | ) |
Adds a column, or array of column names that would be used for an INSERT INTO statement.
array | string | $columns | A column name, or array of column names. |
Implémenté dans DatabaseQuery.
concatenate | ( | $values, | |
$separator = null |
|||
) |
Concatenates an array of column names or values.
Usage: $query->select($query->concatenate(array('a', 'b')));
string[] | $values An array of values to concatenate. | |
string | null | $separator | As separator to place between each value. |
Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.
currentTimestamp | ( | ) |
Gets the current date and time.
Usage: $query->where('published_up < '.$query->currentTimestamp());
Implémenté dans DatabaseQuery, et SqlsrvQuery.
day | ( | $date | ) |
Used to get a string to extract day from date column.
Usage: $query->select($query->day($query->quoteName('dateColumn')));
string | $date | Date column containing day to be extracted. |
Implémenté dans DatabaseQuery.
delete | ( | $table = null | ) |
Add a table name to the DELETE clause of the query.
Usage: $query->delete('#__a')->where('id = 1');
string | $table | The name of the table to delete from. |
QueryTypeAlreadyDefinedException | if the query type has already been defined |
Implémenté dans DatabaseQuery.
exec | ( | $columns | ) |
Add a single column, or array of columns to the EXEC clause of the query.
Usage: $query->exec('a.*')->exec('b.id'); $query->exec(array('a.*', 'b.id'));
array | string | $columns | A string or an array of field names. |
QueryTypeAlreadyDefinedException | if the query type has already been defined |
Implémenté dans DatabaseQuery.
extendWhere | ( | $outerGlue, | |
$conditions, | |||
$innerGlue = 'AND' |
|||
) |
Extend the WHERE clause with a single condition or an array of conditions, with a potentially different logical operator from the one in the current WHERE clause.
Usage: $query->where(array('a = 1', 'b = 2'))->extendWhere('XOR', array('c = 3', 'd = 4')); will produce: WHERE ((a = 1 AND b = 2) XOR (c = 3 AND d = 4)
string | $outerGlue | The glue by which to join the conditions to the current WHERE conditions. |
mixed | $conditions | A string or array of WHERE conditions. |
string | $innerGlue | The glue by which to join the conditions. Defaults to AND. |
Implémenté dans DatabaseQuery.
findInSet | ( | $value, | |
$set | |||
) |
Find a value in a varchar used like a set.
Ensure that the value is an integer before passing to the method.
Usage: $query->findInSet((int) $parent->id, 'a.assigned_cat_ids')
string | $value | The value to search for. |
string | $set | The set of values. |
Implémenté dans DatabaseQuery, et SqlsrvQuery.
from | ( | $table | ) |
Add a table to the FROM clause of the query.
Usage: $query->select('*')->from('#__a'); $query->select('*')->from($subquery->alias('a'));
string | QueryInterface | $table | The name of the table or a QueryInterface object (or a child of it) with alias set. |
Implémenté dans DatabaseQuery.
group | ( | $columns | ) |
Add a grouping column to the GROUP clause of the query.
Usage: $query->group('id');
array | string | $columns | A string or array of ordering columns. |
Implémenté dans DatabaseQuery, et SqlsrvQuery.
groupConcat | ( | $expression, | |
$separator = ',' |
|||
) |
Aggregate function to get input values concatenated into a string, separated by delimiter
Usage: $query->groupConcat('id', ',');
string | $expression | The expression to apply concatenation to, this may be a column name or complex SQL statement. |
string | $separator | The delimiter of each concatenated value |
Implémenté dans SqlsrvQuery, et SqliteQuery.
having | ( | $conditions, | |
$glue = 'AND' |
|||
) |
A conditions to the HAVING clause of the query.
Usage: $query->group('id')->having('COUNT(id) > 5');
array | string | $conditions | A string or array of columns. |
string | $glue | The glue by which to join the conditions. Defaults to AND. |
Implémenté dans DatabaseQuery.
hour | ( | $date | ) |
Used to get a string to extract hour from date column.
Usage: $query->select($query->hour($query->quoteName('dateColumn')));
string | $date | Date column containing hour to be extracted. |
Implémenté dans DatabaseQuery.
insert | ( | $table, | |
$incrementField = false |
|||
) |
Add a table name to the INSERT clause of the 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'));
string | $table | The name of the table to insert data into. |
boolean | $incrementField | The name of the field to auto increment. |
QueryTypeAlreadyDefinedException | if the query type has already been defined |
Implémenté dans DatabaseQuery.
isNullDatetime | ( | $column | ) |
Generate a SQL statement to check if column represents a zero or null datetime.
Usage: $query->where($query->isNullDatetime('modified_date'));
string | $column | A column name. |
Implémenté dans DatabaseQuery.
join | ( | $type, | |
$table, | |||
$condition = null |
|||
) |
Add a JOIN clause to the query.
Usage: $query->join('INNER', 'b', 'b.id = a.id);
string | $type | The type of join. This string is prepended to the JOIN keyword. |
string | $table | The name of table. |
string | $condition | The join condition. |
Implémenté dans DatabaseQuery.
length | ( | $value | ) |
Get the length of a string in bytes.
Note, use 'charLength' to find the number of characters in a string.
Usage: query->where($query->length('a').' > 3');
string | $value | The string to measure. |
Implémenté dans DatabaseQuery, et SqlsrvQuery.
minute | ( | $date | ) |
Used to get a string to extract minute from date column.
Usage: $query->select($query->minute($query->quoteName('dateColumn')));
string | $date | Date column containing minute to be extracted. |
Implémenté dans DatabaseQuery.
month | ( | $date | ) |
Used to get a string to extract month from date column.
Usage: $query->select($query->month($query->quoteName('dateColumn')));
string | $date | Date column containing month to be extracted. |
Implémenté dans DatabaseQuery.
nullDate | ( | $quoted = true | ) |
Get the null or zero representation of a timestamp for the database driver.
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());
boolean | $quoted | Optionally wraps the null date in database quotes (true by default). |
Implémenté dans DatabaseQuery.
order | ( | $columns | ) |
Add an ordering column to the ORDER clause of the query.
Usage: $query->order('foo')->order('bar'); $query->order(array('foo','bar'));
array | string | $columns | A string or array of ordering columns. |
Implémenté dans DatabaseQuery.
querySet | ( | $query | ) |
Set a single query to the query set. On this type of DatabaseQuery you can use union(), unionAll(), order() and setLimit()
Usage: $query->querySet($query2->select('name')->from('#__foo')->order('id DESC')->setLimit(1)) ->unionAll($query3->select('name')->from('#__foo')->order('id')->setLimit(1)) ->order('name') ->setLimit(1)
DatabaseQuery | string | $query | The DatabaseQuery object or string. |
Implémenté dans DatabaseQuery.
rand | ( | ) |
Get the function to return a random floating-point value
Usage: $query->rand();
Implémenté dans DatabaseQuery, et SqlsrvQuery.
regexp | ( | $value | ) |
Get the regular expression operator
Usage: $query->where('field ' . $query->regexp($search));
string | $value | The regex pattern. |
Implémenté dans DatabaseQuery.
second | ( | $date | ) |
Used to get a string to extract seconds from date column.
Usage: $query->select($query->second($query->quoteName('dateColumn')));
string | $date | Date column containing second to be extracted. |
Implémenté dans DatabaseQuery.
select | ( | $columns | ) |
Add a single column, or array of columns to the SELECT clause of the query.
Usage: $query->select('a.*')->select('b.id'); $query->select(array('a.*', 'b.id'));
array | string | $columns | A string or an array of field names. |
QueryTypeAlreadyDefinedException | if the query type has already been defined |
Implémenté dans DatabaseQuery.
selectRowNumber | ( | $orderBy, | |
$orderColumnAlias | |||
) |
Return the number of the current row.
Usage: $query->select('id'); $query->selectRowNumber('ordering,publish_up DESC', 'new_ordering'); $query->from('#__content');
string | $orderBy | An expression of ordering for window function. |
string | $orderColumnAlias | An alias for new ordering column. |
Implémenté dans DatabaseQuery, et SqliteQuery.
set | ( | $conditions, | |
$glue = ',' |
|||
) |
Add a single condition string, or an array of strings to the SET clause of the query.
Usage: $query->set('a = 1')->set('b = 2'); $query->set(array('a = 1', 'b = 2');
array | string | $conditions | A string or array of string conditions. |
string | $glue | The glue by which to join the condition strings. Defaults to , . Note that the glue is set on first use and cannot be changed. |
Implémenté dans DatabaseQuery.
toQuerySet | ( | ) |
Create a DatabaseQuery object of type querySet from current query.
Usage: $query->select('name')->from('#__foo')->order('id DESC')->setLimit(1) ->toQuerySet() ->unionAll($query2->select('name')->from('#__foo')->order('id')->setLimit(1)) ->order('name') ->setLimit(1)
Implémenté dans DatabaseQuery.
union | ( | $query, | |
$distinct = true |
|||
) |
Add a query to UNION with the current query.
Usage: $query->union('SELECT name FROM #__foo') $query->union('SELECT name FROM #__foo', true)
DatabaseQuery | string | $query | The DatabaseQuery object or string to union. |
boolean | $distinct | True to only return distinct rows from the union. |
Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.
unionAll | ( | $query | ) |
Add a query to UNION ALL with the current query.
Usage: $query->unionAll('SELECT name FROM #__foo')
DatabaseQuery | string | $query | The DatabaseQuery object or string to union. |
Implémenté dans DatabaseQuery.
update | ( | $table | ) |
Add a table name to the UPDATE clause of the query.
Usage: $query->update('#__foo')->set(...);
string | $table | A table to update. |
QueryTypeAlreadyDefinedException | if the query type has already been defined |
Implémenté dans DatabaseQuery.
values | ( | $values | ) |
Adds a tuple, or array of tuples that would be used as values for an INSERT INTO statement.
Usage: $query->values('1,2,3')->values('4,5,6'); $query->values(array('1,2,3', '4,5,6'));
array | string | $values | A single tuple, or array of tuples. |
Implémenté dans DatabaseQuery.
where | ( | $conditions, | |
$glue = 'AND' |
|||
) |
Add a single condition, or an array of conditions to the WHERE clause of the query.
Usage: $query->where('a = 1')->where('b = 2'); $query->where(array('a = 1', 'b = 2'));
array | string | $conditions | A string or array of where conditions. |
string | $glue | The glue by which to join the conditions. Defaults to AND. Note that the glue is set on first use and cannot be changed. |
Implémenté dans DatabaseQuery.
whereIn | ( | string | $keyName, |
array | $keyValues, | ||
$dataType = ParameterType::INTEGER |
|||
) |
Add a WHERE IN statement to the query.
Note that all values must be the same data type.
Usage $query->whereIn('id', [1, 2, 3]);
string | $keyName | Key name for the where clause |
array | $keyValues | Array of values to be matched |
array | string | $dataType | Constant corresponding to a SQL datatype. It can be an array, in this case it has to be same length of $keyValues |
Implémenté dans DatabaseQuery.
whereNotIn | ( | string | $keyName, |
array | $keyValues, | ||
$dataType = ParameterType::INTEGER |
|||
) |
Add a WHERE NOT IN statement to the query.
Note that all values must be the same data type.
Usage $query->whereNotIn('id', [1, 2, 3]);
string | $keyName | Key name for the where clause |
array | $keyValues | Array of values to be matched |
array | string | $dataType | Constant corresponding to a SQL datatype. It can be an array, in this case it has to be same length of $keyValues |
Implémenté dans DatabaseQuery.
year | ( | $date | ) |
Used to get a string to extract year from date column.
Usage: $query->select($query->year($query->quoteName('dateColumn')));
string | $date | Date column containing year to be extracted. |
Implémenté dans DatabaseQuery.