Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de l'interface QueryInterface
+ Graphe d'héritage de QueryInterface:

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)
 

Description détaillée

Joomla Framework Query Building Interface.

Depuis
2.0.0

Documentation des fonctions membres

◆ __toString()

__toString ( )

Convert the query object to a string.

Renvoie
string
Depuis
2.0.0

Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.

◆ alias()

alias (   $alias)

Add alias for current query.

Usage: $query->select('*')->from('#__a')->alias('subquery');

Paramètres
string$aliasAlias used for a JDatabaseQuery.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ bindArray()

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)) . ')');

Paramètres
array$valuesValues to bind
array | string$dataTypeConstant corresponding to a SQL datatype. It can be an array, in this case it has to be same length of $key
Renvoie
array An array with parameter names
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ call()

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'));

Paramètres
array | string$columnsA string or an array of field names.
Renvoie
$this
Depuis
2.0.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémenté dans DatabaseQuery.

◆ castAs()

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'));

Paramètres
string$typeThe type of string to cast as.
string$valueThe value to cast as a char.
string$lengthOptionally specify the length of the field (if the type supports it otherwise ignored).
Renvoie
string SQL statement to cast the value as a char type.
Depuis
2.0.0
Exceptions
UnknownTypeExceptionWhen unsupported cast for a database driver

Implémenté dans DatabaseQuery, et SqlsrvQuery.

◆ charLength()

charLength (   $field,
  $operator = null,
  $condition = null 
)

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'));

Paramètres
string$fieldA value.
string | null$operatorComparison operator between charLength integer value and $condition
string | null$conditionInteger value to compare charLength with.
Renvoie
string SQL statement to get the length of a character.
Depuis
2.0.0

Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.

◆ clear()

clear (   $clause = null)

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

Paramètres
string$clauseOptionally, the name of the clause to clear, or nothing to clear the whole query.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ columns()

columns (   $columns)

Adds a column, or array of column names that would be used for an INSERT INTO statement.

Paramètres
array | string$columnsA column name, or array of column names.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ concatenate()

concatenate (   $values,
  $separator = null 
)

Concatenates an array of column names or values.

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

Paramètres
string[]$values An array of values to concatenate.
string | null$separatorAs separator to place between each value.
Renvoie
string SQL statement representing the concatenated values.
Depuis
2.0.0

Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.

◆ currentTimestamp()

currentTimestamp ( )

Gets the current date and time.

Usage: $query->where('published_up < '.$query->currentTimestamp());

Renvoie
string SQL statement to get the current timestamp.
Depuis
2.0.0

Implémenté dans DatabaseQuery, et SqlsrvQuery.

◆ day()

day (   $date)

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

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

Paramètres
string$dateDate column containing day to be extracted.
Renvoie
string SQL statement to get the day from a date value.
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ delete()

delete (   $table = null)

Add a table name to the DELETE clause of the query.

Usage: $query->delete('#__a')->where('id = 1');

Paramètres
string$tableThe name of the table to delete from.
Renvoie
$this
Depuis
2.0.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémenté dans DatabaseQuery.

◆ exec()

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'));

Paramètres
array | string$columnsA string or an array of field names.
Renvoie
$this
Depuis
2.0.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémenté dans DatabaseQuery.

◆ extendWhere()

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)

Paramètres
string$outerGlueThe glue by which to join the conditions to the current WHERE conditions.
mixed$conditionsA string or array of WHERE conditions.
string$innerGlueThe glue by which to join the conditions. Defaults to AND.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ findInSet()

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')

Paramètres
string$valueThe value to search for.
string$setThe set of values.
Renvoie
string A representation of the MySQL find_in_set() function for the driver.
Depuis
2.0.0

Implémenté dans DatabaseQuery, et SqlsrvQuery.

◆ from()

from (   $table)

Add a table to the FROM clause of the query.

Usage: $query->select('*')->from('#__a'); $query->select('*')->from($subquery->alias('a'));

Paramètres
string | QueryInterface$tableThe name of the table or a QueryInterface object (or a child of it) with alias set.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ group()

group (   $columns)

Add a grouping column to the GROUP clause of the query.

Usage: $query->group('id');

Paramètres
array | string$columnsA string or array of ordering columns.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery, et SqlsrvQuery.

◆ groupConcat()

groupConcat (   $expression,
  $separator = ',' 
)

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

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

Paramètres
string$expressionThe expression to apply concatenation to, this may be a column name or complex SQL statement.
string$separatorThe delimiter of each concatenated value
Renvoie
string Input values concatenated into a string, separated by delimiter
Depuis
2.0.0

Implémenté dans SqlsrvQuery, et SqliteQuery.

◆ having()

having (   $conditions,
  $glue = 'AND' 
)

A conditions to the HAVING clause of the query.

Usage: $query->group('id')->having('COUNT(id) > 5');

Paramètres
array | string$conditionsA string or array of columns.
string$glueThe glue by which to join the conditions. Defaults to AND.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ hour()

hour (   $date)

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

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

Paramètres
string$dateDate column containing hour to be extracted.
Renvoie
string SQL statement to get the hour from a date/time value.
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ insert()

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'));

Paramètres
string$tableThe name of the table to insert data into.
boolean$incrementFieldThe name of the field to auto increment.
Renvoie
$this
Depuis
2.0.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémenté dans DatabaseQuery.

◆ isNullDatetime()

isNullDatetime (   $column)

Generate a SQL statement to check if column represents a zero or null datetime.

Usage: $query->where($query->isNullDatetime('modified_date'));

Paramètres
string$columnA column name.
Renvoie
string
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ join()

join (   $type,
  $table,
  $condition = null 
)

Add a JOIN clause to the query.

Usage: $query->join('INNER', 'b', 'b.id = a.id);

Paramètres
string$typeThe type of join. This string is prepended to the JOIN keyword.
string$tableThe name of table.
string$conditionThe join condition.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ length()

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');

Paramètres
string$valueThe string to measure.
Renvoie
integer
Depuis
2.0.0

Implémenté dans DatabaseQuery, et SqlsrvQuery.

◆ minute()

minute (   $date)

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

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

Paramètres
string$dateDate column containing minute to be extracted.
Renvoie
string SQL statement to get the minute from a date/time value.
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ month()

month (   $date)

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

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

Paramètres
string$dateDate column containing month to be extracted.
Renvoie
string SQL statement to get the month from a date value.
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ nullDate()

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());

Paramètres
boolean$quotedOptionally wraps the null date in database quotes (true by default).
Renvoie
string Null or zero representation of a timestamp.
Depuis
2.0.0
Exceptions

Implémenté dans DatabaseQuery.

◆ order()

order (   $columns)

Add an ordering column to the ORDER clause of the query.

Usage: $query->order('foo')->order('bar'); $query->order(array('foo','bar'));

Paramètres
array | string$columnsA string or array of ordering columns.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ querySet()

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)

Paramètres
DatabaseQuery | string$queryThe DatabaseQuery object or string.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ rand()

rand ( )

Get the function to return a random floating-point value

Usage: $query->rand();

Renvoie
string
Depuis
2.0.0

Implémenté dans DatabaseQuery, et SqlsrvQuery.

◆ regexp()

regexp (   $value)

Get the regular expression operator

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

Paramètres
string$valueThe regex pattern.
Renvoie
string
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ second()

second (   $date)

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

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

Paramètres
string$dateDate column containing second to be extracted.
Renvoie
string SQL statement to get the second from a date/time value.
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ select()

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'));

Paramètres
array | string$columnsA string or an array of field names.
Renvoie
$this
Depuis
2.0.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémenté dans DatabaseQuery.

◆ selectRowNumber()

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');

Paramètres
string$orderByAn expression of ordering for window function.
string$orderColumnAliasAn alias for new ordering column.
Renvoie
$this
Depuis
2.0.0
Exceptions

Implémenté dans DatabaseQuery, et SqliteQuery.

◆ set()

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');

Paramètres
array | string$conditionsA string or array of string conditions.
string$glueThe glue by which to join the condition strings. Defaults to ,. Note that the glue is set on first use and cannot be changed.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ toQuerySet()

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)

Renvoie
DatabaseQuery A new object of the DatabaseQuery.
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ union()

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)

Paramètres
DatabaseQuery | string$queryThe DatabaseQuery object or string to union.
boolean$distinctTrue to only return distinct rows from the union.
Renvoie
$this
Depuis
1.0

Implémenté dans DatabaseQuery, SqlsrvQuery, et SqliteQuery.

◆ unionAll()

unionAll (   $query)

Add a query to UNION ALL with the current query.

Usage: $query->unionAll('SELECT name FROM #__foo')

Paramètres
DatabaseQuery | string$queryThe DatabaseQuery object or string to union.
Renvoie
$this
Voir également
union
Depuis
1.5.0

Implémenté dans DatabaseQuery.

◆ update()

update (   $table)

Add a table name to the UPDATE clause of the query.

Usage: $query->update('#__foo')->set(...);

Paramètres
string$tableA table to update.
Renvoie
$this
Depuis
2.0.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémenté dans DatabaseQuery.

◆ values()

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'));

Paramètres
array | string$valuesA single tuple, or array of tuples.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ where()

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'));

Paramètres
array | string$conditionsA string or array of where conditions.
string$glueThe glue by which to join the conditions. Defaults to AND. Note that the glue is set on first use and cannot be changed.
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ whereIn()

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]);

Paramètres
string$keyNameKey name for the where clause
array$keyValuesArray of values to be matched
array | string$dataTypeConstant corresponding to a SQL datatype. It can be an array, in this case it has to be same length of $keyValues
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ whereNotIn()

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]);

Paramètres
string$keyNameKey name for the where clause
array$keyValuesArray of values to be matched
array | string$dataTypeConstant corresponding to a SQL datatype. It can be an array, in this case it has to be same length of $keyValues
Renvoie
$this
Depuis
2.0.0

Implémenté dans DatabaseQuery.

◆ year()

year (   $date)

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

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

Paramètres
string$dateDate column containing year to be extracted.
Renvoie
string SQL statement to get the year from a date value.
Depuis
2.0.0

Implémenté dans DatabaseQuery.


La documentation de cette interface a été générée à partir du fichier suivant :