Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe DatabaseQuery
+ Graphe d'héritage de DatabaseQuery:

Fonctions membres publiques

 __construct (DatabaseInterface $db=null)
 
 __toString ()
 
 __get ($name)
 
 call ($columns)
 
 castAs (string $type, string $value, ?string $length=null)
 
 castAsChar ($value)
 
 charLength ($field, $operator=null, $condition=null)
 
 clear ($clause=null)
 
 columns ($columns)
 
 concatenate ($values, $separator=null)
 
 currentTimestamp ()
 
 dateAdd ($date, $interval, $datePart)
 
 dateFormat ()
 
 dump ()
 
 delete ($table=null)
 
 e ($text, $extra=false)
 
 escape ($text, $extra=false)
 
 exec ($columns)
 
 findInSet ($value, $set)
 
 from ($table)
 
 alias ($alias)
 
 year ($date)
 
 month ($date)
 
 day ($date)
 
 hour ($date)
 
 minute ($date)
 
 second ($date)
 
 group ($columns)
 
 having ($conditions, $glue='AND')
 
 insert ($table, $incrementField=false)
 
 join ($type, $table, $condition=null)
 
 innerJoin ($table, $condition=null)
 
 outerJoin ($table, $condition=null)
 
 leftJoin ($table, $condition=null)
 
 rightJoin ($table, $condition=null)
 
 length ($value)
 
 nullDate ($quoted=true)
 
 isNullDatetime ($column)
 
 order ($columns)
 
 q ($text, $escape=true)
 
 quote ($text, $escape=true)
 
 qn ($name, $as=null)
 
 quoteName ($name, $as=null)
 
 rand ()
 
 regexp ($value)
 
 select ($columns)
 
 set ($conditions, $glue=',')
 
 setLimit ($limit=0, $offset=0)
 
 setQuery ($sql)
 
 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')
 
 orWhere ($conditions, $glue='AND')
 
 andWhere ($conditions, $glue='OR')
 
 bind ($key, &$value, $dataType=ParameterType::STRING, $length=0, $driverOptions=[])
 
 unbind ($key)
 
 bindArray (array $values, $dataType=ParameterType::INTEGER)
 
 __clone ()
 
getBounded ($key=null)
 
 union ($query, $distinct=true)
 
 unionAll ($query)
 
 querySet ($query)
 
 toQuerySet ()
 
 format ($format)
 
 selectRowNumber ($orderBy, $orderColumnAlias)
 
- Fonctions membres publiques hérités de QueryInterface
 groupConcat ($expression, $separator=',')
 
- Fonctions membres publiques hérités de LimitableInterface
 processLimit ($query, $limit, $offset=0)
 

Fonctions membres protégées

 merge ($name, $query)
 
 validateRowNumber ($orderBy, $orderColumnAlias)
 

Attributs protégés

 $bounded = []
 
 $parameterMapping
 
 $db
 
 $sql
 
 $type = ''
 
 $alias = null
 
 $element
 
 $select
 
 $delete
 
 $update
 
 $insert
 
 $from
 
 $join
 
 $set
 
 $where
 
 $group
 
 $having
 
 $columns
 
 $values
 
 $order
 
 $autoIncrementField = false
 
 $call
 
 $exec
 
 $merge
 
 $querySet
 
 $selectRowNumber
 
 $nullDatetimeList = []
 
 $offset
 
 $limit
 
 $preparedIndex = 0
 

Documentation des constructeurs et destructeur

◆ __construct()

__construct ( DatabaseInterface  $db = null)

Class constructor.

Paramètres
DatabaseInterface$dbThe database driver.
Depuis
1.0

Références DatabaseQuery\$db.

Documentation des fonctions membres

◆ __clone()

__clone ( )

Method to provide basic copy support.

Any object pushed into the data of this class should have its own __clone() implementation. This method does not support copying objects in a multidimensional array.

Renvoie
void
Depuis
1.0

Références DatabaseQuery\$element, $i, $this, et elseif.

◆ __get()

__get (   $name)

Magic function to get protected variable value

Paramètres
string$nameThe name of the variable.
Renvoie
mixed
Depuis
1.0

Références $name, et $this.

◆ __toString()

◆ 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émente QueryInterface.

Références DatabaseQuery\$alias, et $this.

Référencé par SqlsrvQuery\__toString(), DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ andWhere()

andWhere (   $conditions,
  $glue = 'OR' 
)

Extend the WHERE clause with an AND and a single condition or an array of conditions.

Usage: $query->where(array('a = 1', 'b = 2'))->andWhere(array('c = 3', 'd = 4')); will produce: WHERE ((a = 1 AND b = 2) AND (c = 3 OR d = 4)

Paramètres
mixed$conditionsA string or array of WHERE conditions.
string$glueThe glue by which to join the conditions. Defaults to OR.
Renvoie
$this
Depuis
1.3.0

Références DatabaseQuery\extendWhere().

◆ bind()

bind (   $key,
$value,
  $dataType = ParameterType::STRING,
  $length = 0,
  $driverOptions = [] 
)

Method to add a variable to an internal array that will be bound to a prepared SQL statement before query execution.

Paramètres
array | string | integer$keyThe key that will be used in your SQL query to reference the value. Usually of the form ':key', but can also be an integer.
mixed$valueThe value that will be bound. It can be an array, in this case it has to be same length of $key; The value is passed by reference to support output parameters such as those possible with stored procedures.
array | string$dataTypeConstant corresponding to a SQL datatype. It can be an array, in this case it has to be same length of $key
integer$lengthThe length of the variable. Usually required for OUTPUT parameters.
array$driverOptionsOptional driver options to be used.
Renvoie
$this
Depuis
1.5.0
Exceptions

Implémente PreparableInterface.

Références $count, $key, $this, et $value.

Référencé par DatabaseQuery\bindArray().

◆ 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->where('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émente QueryInterface.

Références $i, DatabaseQuery\$preparedIndex, DatabaseQuery\$values, et DatabaseQuery\bind().

Référencé par DatabaseQuery\whereIn(), et DatabaseQuery\whereNotIn().

◆ 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
mixed$columnsA string or an array of field names.
Renvoie
$this
Depuis
1.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémente QueryInterface.

Références DatabaseQuery\$columns, $this, et null.

Référencé par DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ castAs()

castAs ( string  $type,
string  $value,
?string  $length = null 
)

Casts a value to a char.

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
1.0

Implémente QueryInterface.

Références DatabaseQuery\$type, et $value.

Référencé par DatabaseQuery\castAsChar().

◆ castAsChar()

castAsChar (   $value)

Casts a value to a char.

Ensure that the value is properly quoted before passing to the method.

Usage: $query->select($query->castAsChar('a'));

Paramètres
string$valueThe value to cast as a char.
Renvoie
string SQL statement to cast the value as a char type.
Depuis
1.0
Obsolète:
3.0 Use $query->castAs('CHAR', $value)

Références $value, et DatabaseQuery\castAs().

◆ 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 The required char length call.
Depuis
1.0

Implémente QueryInterface.

Références $field, et null.

◆ clear()

◆ 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
1.0

Implémente QueryInterface.

Références DatabaseQuery\$columns, $this, et null.

Référencé par SqliteQuery\__toString(), SqlsrvQuery\__toString(), DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ 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 The concatenated values.
Depuis
1.0

Implémente QueryInterface.

Références $separator, DatabaseQuery\$values, null, et DatabaseQuery\quote().

◆ currentTimestamp()

currentTimestamp ( )

Gets the current date and time.

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

Renvoie
string
Depuis
1.0

Implémente QueryInterface.

◆ dateAdd()

dateAdd (   $date,
  $interval,
  $datePart 
)

Add to the current date and time.

Usage: $query->select($query->dateAdd());

Prefixing the interval with a - (negative sign) will cause subtraction to be used. Note: Not all drivers support all units.

Paramètres
string$dateThe db quoted string representation of the date to add to. May be date or datetime
string$intervalThe string representation of the appropriate number of units
string$datePartThe part of the date to perform the addition on
Renvoie
string The string with the appropriate sql for addition of dates

1.5.0

Références $date.

◆ dateFormat()

dateFormat ( )

Returns a PHP date() function compliant date format 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 getDateFormat method directly.

Renvoie
string The format string.
Depuis
1.0
Exceptions

Références class.

◆ 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 Returns string to extract day from a date.
Depuis
1.0

Implémente QueryInterface.

Références $date.

◆ 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
1.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémente QueryInterface.

Références $this, DatabaseQuery\from(), et null.

◆ dump()

dump ( )

Creates a HTML formatted dump of the query for debugging purposes.

Usage: echo $query->dump();

Renvoie
string
Depuis
1.0
Obsolète:
3.0 Deprecated without replacement

Références $this.

◆ e()

e (   $text,
  $extra = false 
)

Alias for escape method

Paramètres
string$textThe string to be escaped.
boolean$extraOptional parameter to provide extra escaping.
Renvoie
string The escaped string.
Depuis
1.0
Exceptions

Références $text, et DatabaseQuery\escape().

◆ escape()

escape (   $text,
  $extra = false 
)

Method to escape a string for usage in an SQL statement.

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 DatabaseDriver.

Paramètres
string$textThe string to be escaped.
boolean$extraOptional parameter to provide extra escaping.
Renvoie
string The escaped string.
Depuis
1.0
Exceptions

Références $text, et class.

Référencé par DatabaseQuery\e().

◆ 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
1.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémente QueryInterface.

Références DatabaseQuery\$columns, $this, et null.

Référencé par DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ 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
1.3.0

Implémente QueryInterface.

Références $this, et DatabaseQuery\where().

Référencé par DatabaseQuery\andWhere(), et DatabaseQuery\orWhere().

◆ 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
1.5.0

Implémente QueryInterface.

◆ format()

format (   $format)

Find and replace sprintf-like tokens in a format string. Each token takes one of the following forms: %% - A literal percent character. %[t] - Where [t] is a type specifier. %[n]$[x] - Where [n] is an argument specifier and [t] is a type specifier.

Types: a - Numeric: Replacement text is coerced to a numeric type but not quoted or escaped. e - Escape: Replacement text is passed to $this->escape(). E - Escape (extra): Replacement text is passed to $this->escape() with true as the second argument. n - Name Quote: Replacement text is passed to $this->quoteName(). q - Quote: Replacement text is passed to $this->quote(). Q - Quote (no escape): Replacement text is passed to $this->quote() with false as the second argument. r - Raw: Replacement text is used as-is. (Be careful)

Date Types:

  • Replacement text automatically quoted (use uppercase for Name Quote).
  • Replacement text should be a string in date format or name of a date column. y/Y - Year m/M - Month d/D - Day h/H - Hour i/I - Minute s/S - Second

Invariable Types:

  • Takes no argument.
  • Argument index not incremented. t - Replacement text is the result of $this->currentTimestamp(). z - Replacement text is the result of $this->nullDate(false). Z - Replacement text is the result of $this->nullDate(true).

Usage: $query->format('SELECT %1$n FROM %2$n WHERE %3$n = %4$a', 'foo', '#__foo', 'bar', 1); Returns: SELECT foo FROM #__foo WHERE bar = 1

Notes: The argument specifier is optional but recommended for clarity. The argument index used for unspecified tokens is incremented only when used.

Paramètres
string$formatThe formatting string.
Renvoie
string Returns a string produced according to the formatting string.
Depuis
1.0

Regexp to find an replace all tokens. Matched fields: 0: Full token 1: Everything following '' 2: Everything following '' unless '' 3: Argument specifier and '$' 4: Argument specifier 5: Type specifier 6: '' if full token is '%'

Références $format, $i, $query, $this, et null.

◆ 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 | DatabaseQuery$tableThe name of the table or a DatabaseQuery object (or a child of it) with alias set.
Renvoie
$this
Depuis
1.0
Exceptions

Implémente QueryInterface.

Références $this, et null.

Référencé par SqliteQuery\__toString(), SqlsrvQuery\__toString(), DatabaseQuery\__toString(), DatabaseQuery\clear(), DatabaseQuery\delete(), SqlsrvQuery\fixGroupColumns(), et SqlsrvQuery\group().

◆ getBounded()

& getBounded (   $key = null)

Retrieves the bound parameters array when key is null and returns it by reference. If a key is provided then that item is returned.

Paramètres
mixed$keyThe bounded variable key to retrieve.
Renvoie
mixed
Depuis
1.5.0

Implémente PreparableInterface.

Références DatabaseQuery\$bounded, et $key.

◆ 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
1.0

Implémente QueryInterface.

Références DatabaseQuery\$columns, $this, et null.

Référencé par DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ 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
1.0

Implémente QueryInterface.

Références $this, et null.

Référencé par SqlsrvQuery\__toString(), DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ 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 Returns string to extract hour from a date.
Depuis
1.0

Implémente QueryInterface.

Références $date.

◆ innerJoin()

innerJoin (   $table,
  $condition = null 
)

Add an INNER JOIN clause to the query.

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

Paramètres
string$tableThe name of table.
string$conditionThe join condition.
Renvoie
$this
Depuis
1.0

Références DatabaseQuery\join().

◆ 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
1.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémente QueryInterface.

Références $this, et null.

Référencé par SqlsrvQuery\__toString(), DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ 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émente QueryInterface.

Références $this, et class.

◆ 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
1.0

Implémente QueryInterface.

Références $this, DatabaseQuery\$type, et null.

Référencé par SqliteQuery\__toString(), SqlsrvQuery\__toString(), DatabaseQuery\__toString(), DatabaseQuery\clear(), SqlsrvQuery\fixGroupColumns(), SqlsrvQuery\group(), DatabaseQuery\innerJoin(), DatabaseQuery\leftJoin(), DatabaseQuery\outerJoin(), et DatabaseQuery\rightJoin().

◆ leftJoin()

leftJoin (   $table,
  $condition = null 
)

Add a LEFT JOIN clause to the query.

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

Paramètres
string$tableThe name of table.
string$conditionThe join condition.
Renvoie
$this
Depuis
1.0

Références DatabaseQuery\join().

◆ 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
1.0

Implémente QueryInterface.

Références $value.

◆ merge()

merge (   $name,
  $query 
)
protected

Combine a select statement to the current query by one of the set operators. Operators: UNION, UNION ALL, EXCEPT or INTERSECT.

Paramètres
string$nameThe name of the set operator with parentheses.
DatabaseQuery | string$queryThe DatabaseQuery object or string.
Renvoie
$this
Depuis
2.0.0

Références $name, $query, et $this.

Référencé par SqliteQuery\__toString(), SqlsrvQuery\__toString(), DatabaseQuery\__toString(), DatabaseQuery\clear(), SqliteQuery\union(), SqlsrvQuery\union(), et DatabaseQuery\union().

◆ 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 Returns string to extract minute from a date.
Depuis
1.0

Implémente QueryInterface.

Références $date.

◆ 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 Returns string to extract month from a date.
Depuis
1.0

Implémente QueryInterface.

Références $date.

◆ 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
1.0
Exceptions

Implémente QueryInterface.

Références $result, et class.

◆ order()

order (   $columns)

Add a 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
1.0

Implémente QueryInterface.

Références DatabaseQuery\$columns, $this, et null.

Référencé par SqliteQuery\__toString(), SqlsrvQuery\__toString(), DatabaseQuery\__toString(), DatabaseQuery\clear(), et SqlsrvQuery\fixGroupColumns().

◆ orWhere()

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

Extend the WHERE clause with an OR and a single condition or an array of conditions.

Usage: $query->where(array('a = 1', 'b = 2'))->orWhere(array('c = 3', 'd = 4')); will produce: WHERE ((a = 1 AND b = 2) OR (c = 3 AND d = 4)

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

Références DatabaseQuery\extendWhere().

◆ outerJoin()

outerJoin (   $table,
  $condition = null 
)

Add an OUTER JOIN clause to the query.

Usage: $query->outerJoin('b', 'b.id = a.id')->leftJoin('c', 'c.id = b.id');

Paramètres
string$tableThe name of table.
string$conditionThe join condition.
Renvoie
$this
Depuis
1.0

Références DatabaseQuery\join().

◆ q()

q (   $text,
  $escape = true 
)

Alias for quote method

Paramètres
array | string$textA string or an array of strings to quote.
boolean$escapeTrue (default) to escape the string, false to leave it unchanged.
Renvoie
string The quoted input string.
Depuis
1.0
Exceptions

Références $text, et DatabaseQuery\quote().

◆ qn()

qn (   $name,
  $as = null 
)

Alias for quoteName method

Paramètres
array | string$nameThe identifier name to wrap in quotes, or an array of identifier names to wrap in quotes. Each type supports dot-notation name.
array | string$asThe AS query part associated to $name. It can be string or array, in latter case it has to be same length of $name; if is null there will not be any AS part for string or array element.
Renvoie
array|string The quote wrapped name, same type of $name.
Depuis
1.0
Exceptions

Références $name, et DatabaseQuery\quoteName().

◆ 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$queryThe DatabaseQuery object or string.
Renvoie
$this
Depuis
2.0.0

Implémente QueryInterface.

Références $query, et $this.

Référencé par DatabaseQuery\clear().

◆ quote()

quote (   $text,
  $escape = true 
)

Method to quote and optionally escape a string to database requirements for insertion into the database.

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

Paramètres
array | string$textA string or an array of strings to quote.
boolean$escapeTrue (default) to escape the string, false to leave it unchanged.
Renvoie
string The quoted input string.
Depuis
1.0
Exceptions

Références $text, et class.

Référencé par SqliteQuery\concatenate(), SqlsrvQuery\concatenate(), DatabaseQuery\concatenate(), SqliteQuery\groupConcat(), SqlsrvQuery\groupConcat(), et DatabaseQuery\q().

◆ quoteName()

quoteName (   $name,
  $as = null 
)

Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection risks and reserved word conflicts.

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 DatabaseDriver.

Usage: $query->quoteName('#__a'); $query->qn('#__a');

Paramètres
array | string$nameThe identifier name to wrap in quotes, or an array of identifier names to wrap in quotes. Each type supports dot-notation name.
array | string$asThe AS query part associated to $name. It can be string or array, in latter case it has to be same length of $name; if is null there will not be any AS part for string or array element.
Renvoie
array|string The quote wrapped name, same type of $name.
Depuis
1.0
Exceptions

Références $name, et class.

Référencé par SqlsrvQuery\fixSelectAliases(), et DatabaseQuery\qn().

◆ rand()

rand ( )

Get the function to return a random floating-point value

Usage: $query->rand();

Renvoie
string
Depuis
1.5.0

Implémente QueryInterface.

◆ regexp()

regexp (   $value)

Get the regular expression operator

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

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

Implémente QueryInterface.

Références $value.

◆ rightJoin()

rightJoin (   $table,
  $condition = null 
)

Add a RIGHT JOIN clause to the query.

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

Paramètres
string$tableThe name of table.
string$conditionThe join condition.
Renvoie
$this
Depuis
1.0

Références DatabaseQuery\join().

◆ 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 Returns string to extract second from a date.
Depuis
1.0

Implémente QueryInterface.

Références $date.

◆ select()

select (   $columns)

Add a single column, or array of columns to the SELECT clause of the query.

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

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

Implémente QueryInterface.

Références DatabaseQuery\$columns, $this, et null.

Référencé par SqliteQuery\__toString(), SqlsrvQuery\__toString(), DatabaseQuery\__toString(), DatabaseQuery\clear(), SqlsrvQuery\fixSelectAliases(), SqlsrvQuery\group(), et DatabaseQuery\selectRowNumber().

◆ 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émente QueryInterface.

Références DatabaseQuery\select(), et DatabaseQuery\validateRowNumber().

Référencé par SqlsrvQuery\__toString(), DatabaseQuery\__toString(), DatabaseQuery\clear(), et DatabaseQuery\validateRowNumber().

◆ 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
1.0

Implémente QueryInterface.

Références $this, et null.

◆ setLimit()

setLimit (   $limit = 0,
  $offset = 0 
)

Sets the offset and limit for the result set, if the database driver supports it.

Usage: $query->setLimit(100, 0); (retrieve 100 rows, starting at first record) $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th record)

Paramètres
integer$limitThe limit for the result set
integer$offsetThe offset for the result set
Renvoie
$this
Depuis
2.0.0

Implémente LimitableInterface.

Références DatabaseQuery\$limit, DatabaseQuery\$offset, $this, Joomla\Database\Query\limit(), et Joomla\Database\Query\offset().

◆ setQuery()

setQuery (   $sql)

Allows a direct query to be provided to the database driver's setQuery() method, but still allow queries to have bounded variables.

Usage: $query->setQuery('select * from #__users');

Paramètres
DatabaseQuery | string$sqlA SQL query string or DatabaseQuery object
Renvoie
$this
Depuis
1.0

Références DatabaseQuery\$sql, et $this.

◆ 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émente QueryInterface.

Références $this.

◆ unbind()

unbind (   $key)

Method to unbind a bound variable.

Paramètres
array | string | integer$keyThe key or array of keys to unbind.
Renvoie
$this
Depuis
2.0.0

Implémente PreparableInterface.

Références $key, et $this.

◆ 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émente QueryInterface.

Références $query, et DatabaseQuery\merge().

◆ 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émente QueryInterface.

Références $query.

◆ 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
1.0
Exceptions
QueryTypeAlreadyDefinedExceptionif the query type has already been defined

Implémente QueryInterface.

Références $this, et null.

Référencé par SqliteQuery\__toString(), SqlsrvQuery\__toString(), DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ validateRowNumber()

validateRowNumber (   $orderBy,
  $orderColumnAlias 
)
protected

Validate arguments which are passed to selectRowNumber method and set up common variables.

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

Références DatabaseQuery\selectRowNumber().

Référencé par SqliteQuery\selectRowNumber(), et DatabaseQuery\selectRowNumber().

◆ 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
1.0

Implémente QueryInterface.

Références $this, DatabaseQuery\$values, et null.

Référencé par SqlsrvQuery\__toString(), DatabaseQuery\__toString(), et DatabaseQuery\clear().

◆ 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
1.0

Implémente QueryInterface.

Références $this, et null.

Référencé par SqlsrvQuery\__toString(), DatabaseQuery\__toString(), DatabaseQuery\clear(), DatabaseQuery\extendWhere(), DatabaseQuery\whereIn(), et DatabaseQuery\whereNotIn().

◆ 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émente QueryInterface.

Références DatabaseQuery\bindArray(), et DatabaseQuery\where().

◆ 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émente QueryInterface.

Références DatabaseQuery\bindArray(), et DatabaseQuery\where().

◆ 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 Returns string to extract year from a date.
Depuis
1.0

Implémente QueryInterface.

Références $date.

Documentation des champs

◆ $alias

◆ $autoIncrementField

$autoIncrementField = false
protected

◆ $bounded

$bounded = []
protected

Référencé par DatabaseQuery\getBounded().

◆ $call

$call
protected

◆ $columns

◆ $db

$db
protected

◆ $delete

$delete
protected

◆ $element

◆ $exec

$exec
protected

◆ $from

$from
protected

Référencé par SqlsrvQuery\__toString().

◆ $group

$group
protected

◆ $having

$having
protected

◆ $insert

$insert
protected

◆ $join

◆ $limit

◆ $merge

$merge
protected

◆ $nullDatetimeList

$nullDatetimeList = []
protected

◆ $offset

◆ $order

$order
protected

Référencé par SqliteQuery\__toString().

◆ $parameterMapping

$parameterMapping
protected

◆ $preparedIndex

$preparedIndex = 0
protected

Référencé par DatabaseQuery\bindArray().

◆ $querySet

◆ $select

$select
protected

Référencé par SqliteQuery\__toString().

◆ $selectRowNumber

$selectRowNumber
protected

◆ $set

$set
protected

◆ $sql

$sql
protected

◆ $type

◆ $update

$update
protected

Référencé par SqlsrvQuery\__toString().

◆ $values

◆ $where

$where
protected

Référencé par SqliteQuery\__toString().


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