code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
public function add(PluginInterface $plugin) { $name = $plugin->getName(); if (isset($this->plugins[$name])) { throw new CakeException(sprintf('Plugin named `%s` is already loaded', $name)); } $this->plugins[$name] = $plugin; $this->names = array_keys($this->plugins); return $this; }
Add a plugin to the collection Plugins will be keyed by their names. @param \Cake\Core\PluginInterface $plugin The plugin to load. @return $this
add
php
cakephp/cakephp
src/Core/PluginCollection.php
https://github.com/cakephp/cakephp/blob/master/src/Core/PluginCollection.php
MIT
public function remove(string $name) { unset($this->plugins[$name]); $this->names = array_keys($this->plugins); return $this; }
Remove a plugin from the collection if it exists. @param string $name The named plugin. @return $this
remove
php
cakephp/cakephp
src/Core/PluginCollection.php
https://github.com/cakephp/cakephp/blob/master/src/Core/PluginCollection.php
MIT
public function clear() { $this->plugins = []; $this->names = []; $this->positions = []; $this->loopDepth = -1; return $this; }
Remove all plugins from the collection @return $this
clear
php
cakephp/cakephp
src/Core/PluginCollection.php
https://github.com/cakephp/cakephp/blob/master/src/Core/PluginCollection.php
MIT
public function mockService(string $class, Closure $factory) { $this->containerServices[$class] = $factory; return $this; }
Add a mocked service to the container. When the container is created the provided classname will be mapped to the factory function. The factory function will be used to create mocked services. @param string $class The class or interface you want to define. @param \Closure $factory The factory function for mocked services. @return $this
mockService
php
cakephp/cakephp
src/Core/TestSuite/ContainerStubTrait.php
https://github.com/cakephp/cakephp/blob/master/src/Core/TestSuite/ContainerStubTrait.php
MIT
public function removeMockService(string $class) { unset($this->containerServices[$class]); return $this; }
Remove a mocked service to the container. @param string $class The class or interface you want to remove. @return $this
removeMockService
php
cakephp/cakephp
src/Core/TestSuite/ContainerStubTrait.php
https://github.com/cakephp/cakephp/blob/master/src/Core/TestSuite/ContainerStubTrait.php
MIT
public function __construct(RetryStrategyInterface $strategy, int $maxRetries = 1) { $this->strategy = $strategy; $this->maxRetries = $maxRetries; }
Creates the CommandRetry object with the given strategy and retry count @param \Cake\Core\Retry\RetryStrategyInterface $strategy The strategy to follow should the action fail @param int $maxRetries The maximum number of retry attempts allowed
__construct
php
cakephp/cakephp
src/Core/Retry/CommandRetry.php
https://github.com/cakephp/cakephp/blob/master/src/Core/Retry/CommandRetry.php
MIT
public function __construct(?string $path = null, ?string $section = null) { $this->_path = $path ?? CONFIG; $this->_section = $section; }
Build and construct a new ini file parser. The parser can be used to read ini files that are on the filesystem. @param string|null $path Path to load ini config files from. Defaults to CONFIG. @param string|null $section Only get one section, leave null to parse and fetch all sections in the ini file.
__construct
php
cakephp/cakephp
src/Core/Configure/Engine/IniConfig.php
https://github.com/cakephp/cakephp/blob/master/src/Core/Configure/Engine/IniConfig.php
MIT
public function __construct(?string $path = null) { $this->_path = $path ?? CONFIG; }
Constructor for JSON Config file reading. @param string|null $path The path to read config files from. Defaults to CONFIG.
__construct
php
cakephp/cakephp
src/Core/Configure/Engine/JsonConfig.php
https://github.com/cakephp/cakephp/blob/master/src/Core/Configure/Engine/JsonConfig.php
MIT
public function __construct(array|string $message = '', ?int $code = null, ?Throwable $previous = null) { if (is_array($message)) { $this->_attributes = $message; $message = vsprintf($this->_messageTemplate, $message); } parent::__construct($message, $code ?? $this->_defaultCode, $previous); }
Constructor. Allows you to create exceptions that are treated as framework errors and disabled when debug mode is off. @param array|string $message Either the string of the error message, or an array of attributes that are made available in the view, and sprintf()'d into Exception::$_messageTemplate @param int|null $code The error code @param \Throwable|null $previous the previous exception.
__construct
php
cakephp/cakephp
src/Core/Exception/CakeException.php
https://github.com/cakephp/cakephp/blob/master/src/Core/Exception/CakeException.php
MIT
public function __construct(Connection $connection) { $this->setConnection($connection); }
Constructor. @param \Cake\Database\Connection $connection The connection object to be used for transforming and executing this query
__construct
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function setConnection(Connection $connection) { $this->_dirty(); $this->_connection = $connection; return $this; }
Sets the connection instance to be used for executing and transforming this query. @param \Cake\Database\Connection $connection Connection instance @return $this
setConnection
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function from(array|string $tables = [], bool $overwrite = false) { $tables = (array)$tables; if ($overwrite) { $this->_parts['from'] = $tables; } else { $this->_parts['from'] = array_merge($this->_parts['from'], $tables); } $this->_dirty(); return $this; }
Adds a single or multiple tables to be used in the FROM clause for this query. Tables can be passed as an array of strings, array of expression objects, a single expression or a single string. If an array is passed, keys will be used to alias tables using the value as the real field to be aliased. It is possible to alias strings, ExpressionInterface objects or even other Query objects. By default this function will append any passed argument to the list of tables to be selected from, unless the second argument is set to true. This method can be used for select, update and delete statements. ### Examples: ``` $query->from(['p' => 'posts']); // Produces FROM posts p $query->from('authors'); // Appends authors: FROM posts p, authors $query->from(['products'], true); // Resets the list: FROM products $query->from(['sub' => $countQuery]); // FROM (SELECT ...) sub ``` @param array|string $tables tables to be added to the list. This argument, can be passed as an array of strings, array of expression objects, or a single string. See the examples above for the valid call types. @param bool $overwrite whether to reset tables with passed list or not @return $this
from
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function removeJoin(string $name) { unset($this->_parts['join'][$name]); $this->_dirty(); return $this; }
Remove a join if it has been defined. Useful when you are redefining joins or want to re-order the join clauses. @param string $name The alias/name of the join to remove. @return $this
removeJoin
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function rightJoin( array|string $table, ExpressionInterface|Closure|array|string $conditions = [], array $types = [], ) { $this->join($this->_makeJoin($table, $conditions, static::JOIN_TYPE_RIGHT), $types); return $this; }
Adds a single `RIGHT JOIN` clause to the query. This is a shorthand method for building joins via `join()`. The arguments of this method are identical to the `leftJoin()` shorthand, please refer to that methods description for further details. @param array<string, string|\Cake\Database\Query\SelectQuery>|string $table The table to join with @param \Cake\Database\ExpressionInterface|\Closure|array|string $conditions The conditions to use for joining. @param array $types a list of types associated to the conditions used for converting values to the corresponding database representation. @return $this
rightJoin
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function innerJoin( array|string $table, ExpressionInterface|Closure|array|string $conditions = [], array $types = [], ) { $this->join($this->_makeJoin($table, $conditions, static::JOIN_TYPE_INNER), $types); return $this; }
Adds a single `INNER JOIN` clause to the query. This is a shorthand method for building joins via `join()`. The arguments of this method are identical to the `leftJoin()` shorthand, please refer to that method's description for further details. @param array<string, string|\Cake\Database\Query\SelectQuery>|string $table The table to join with @param \Cake\Database\ExpressionInterface|\Closure|array|string $conditions The conditions to use for joining. @param array<string, string> $types a list of types associated to the conditions used for converting values to the corresponding database representation. @return $this
innerJoin
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function whereInList(string $field, array $values, array $options = []) { $options += [ 'types' => [], 'allowEmpty' => false, ]; if ($options['allowEmpty'] && !$values) { return $this->where('1=0'); } return $this->where([$field . ' IN' => $values], $options['types']); }
Adds an IN condition or set of conditions to be used in the WHERE clause for this query. This method does allow empty inputs in contrast to where() if you set 'allowEmpty' to true. Be careful about using it without proper sanity checks. Options: - `types` - Associative array of type names used to bind values to query - `allowEmpty` - Allow empty array. @param string $field Field @param array $values Array of values @param array<string, mixed> $options Options @return $this
whereInList
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function whereNotInList(string $field, array $values, array $options = []) { $options += [ 'types' => [], 'allowEmpty' => false, ]; if ($options['allowEmpty'] && !$values) { return $this->where([$field . ' IS NOT' => null]); } return $this->where([$field . ' NOT IN' => $values], $options['types']); }
Adds a NOT IN condition or set of conditions to be used in the WHERE clause for this query. This method does allow empty inputs in contrast to where() if you set 'allowEmpty' to true. Be careful about using it without proper sanity checks. @param string $field Field @param array $values Array of values @param array<string, mixed> $options Options @return $this
whereNotInList
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function orderAsc(ExpressionInterface|Closure|string $field, bool $overwrite = false) { deprecationWarning('5.0.0', 'Query::orderAsc() is deprecated. Use Query::orderByAsc() instead.'); return $this->orderByAsc($field, $overwrite); }
Add an ORDER BY clause with an ASC direction. This method allows you to set complex expressions as order conditions unlike order() Order fields are not suitable for use with user supplied data as they are not sanitized by the query builder. @param \Cake\Database\ExpressionInterface|\Closure|string $field The field to order on. @param bool $overwrite Whether to reset the order clauses. @return $this @deprecated 5.0.0 Use orderByAsc() instead now that CollectionInterface methods are no longer proxied.
orderAsc
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function orderByAsc(ExpressionInterface|Closure|string $field, bool $overwrite = false) { if ($overwrite) { $this->_parts['order'] = null; } if (!$field) { return $this; } if ($field instanceof Closure) { $field = $field($this->newExpr(), $this); } $this->_parts['order'] ??= new OrderByExpression(); /** @var \Cake\Database\Expression\QueryExpression $queryExpr */ $queryExpr = $this->_parts['order']; $queryExpr->add(new OrderClauseExpression($field, 'ASC')); return $this; }
Add an ORDER BY clause with an ASC direction. This method allows you to set complex expressions as order conditions unlike order() Order fields are not suitable for use with user supplied data as they are not sanitized by the query builder. @param \Cake\Database\ExpressionInterface|\Closure|string $field The field to order on. @param bool $overwrite Whether to reset the order clauses. @return $this
orderByAsc
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function orderDesc(ExpressionInterface|Closure|string $field, bool $overwrite = false) { deprecationWarning('5.0.0', 'Query::orderDesc() is deprecated. Use Query::orderByDesc() instead.'); return $this->orderByDesc($field, $overwrite); }
Add an ORDER BY clause with a DESC direction. This method allows you to set complex expressions as order conditions unlike order() Order fields are not suitable for use with user supplied data as they are not sanitized by the query builder. @param \Cake\Database\ExpressionInterface|\Closure|string $field The field to order on. @param bool $overwrite Whether to reset the order clauses. @return $this @deprecated 5.0.0 Use orderByDesc() instead now that CollectionInterface methods are no longer proxied.
orderDesc
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function orderByDesc(ExpressionInterface|Closure|string $field, bool $overwrite = false) { if ($overwrite) { $this->_parts['order'] = null; } if (!$field) { return $this; } if ($field instanceof Closure) { $field = $field($this->newExpr(), $this); } $this->_parts['order'] ??= new OrderByExpression(); /** @var \Cake\Database\Expression\QueryExpression $queryExpr */ $queryExpr = $this->_parts['order']; $queryExpr->add(new OrderClauseExpression($field, 'DESC')); return $this; }
Add an ORDER BY clause with a DESC direction. This method allows you to set complex expressions as order conditions unlike order() Order fields are not suitable for use with user supplied data as they are not sanitized by the query builder. @param \Cake\Database\ExpressionInterface|\Closure|string $field The field to order on. @param bool $overwrite Whether to reset the order clauses. @return $this
orderByDesc
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function page(int $num, ?int $limit = null) { throw new CakeException('Not implemented'); }
Set the page of results you want. This method provides an easier to use interface to set the limit + offset in the record set you want as results. If empty the limit will default to the existing limit clause, and if that too is empty, then `25` will be used. Pages must start at 1. @param int $num The page number you want. @param int|null $limit The number of rows you want in the page. If null the current limit clause will be used. @return $this @throws \Cake\Core\Exception\CakeException If page number < 1.
page
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function limit(ExpressionInterface|int|null $limit) { $this->_dirty(); $this->_parts['limit'] = $limit; return $this; }
Sets the number of records that should be retrieved from database, accepts an integer or an expression object that evaluates to an integer. In some databases, this operation might not be supported or will require the query to be transformed in order to limit the result set size. ### Examples ``` $query->limit(10) // generates LIMIT 10 $query->limit($query->newExpr()->add(['1 + 1'])); // LIMIT (1 + 1) ``` @param \Cake\Database\ExpressionInterface|int|null $limit number of records to be returned @return $this
limit
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function offset(ExpressionInterface|int|null $offset) { $this->_dirty(); $this->_parts['offset'] = $offset; return $this; }
Sets the number of records that should be skipped from the original result set This is commonly used for paginating large results. Accepts an integer or an expression object that evaluates to an integer. In some databases, this operation might not be supported or will require the query to be transformed in order to limit the result set size. ### Examples ``` $query->offset(10) // generates OFFSET 10 $query->offset($query->newExpr()->add(['1 + 1'])); // OFFSET (1 + 1) ``` @param \Cake\Database\ExpressionInterface|int|null $offset number of records to be skipped @return $this
offset
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function setValueBinder(?ValueBinder $binder) { $this->_valueBinder = $binder; return $this; }
Overwrite the current value binder A ValueBinder is responsible for generating query placeholders and temporarily associate values to those placeholders so that they can be passed correctly to the statement object. @param \Cake\Database\ValueBinder|null $binder The binder or null to disable binding. @return $this
setValueBinder
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function __clone() { $this->_statement = null; if ($this->_valueBinder !== null) { $this->_valueBinder = clone $this->_valueBinder; } foreach ($this->_parts as $name => $part) { if (!$part) { continue; } if (is_array($part)) { foreach ($part as $i => $piece) { if (is_array($piece)) { foreach ($piece as $j => $value) { if ($value instanceof ExpressionInterface) { $this->_parts[$name][$i][$j] = clone $value; } } } elseif ($piece instanceof ExpressionInterface) { $this->_parts[$name][$i] = clone $piece; } } } if ($part instanceof ExpressionInterface) { $this->_parts[$name] = clone $part; } } }
Handles clearing iterator and cloning all expressions and value binders. @return void
__clone
php
cakephp/cakephp
src/Database/Query.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query.php
MIT
public function __construct(array $defaults = []) { $this->setDefaults($defaults); }
Creates an instance with the given defaults @param array<int|string, string> $defaults The defaults to use.
__construct
php
cakephp/cakephp
src/Database/TypeMap.php
https://github.com/cakephp/cakephp/blob/master/src/Database/TypeMap.php
MIT
public function enableAutoQuoting(bool $enable = true) { $this->_autoQuoting = $enable; return $this; }
Sets whether this driver should automatically quote identifiers in queries. @param bool $enable Whether to enable auto quoting @return $this
enableAutoQuoting
php
cakephp/cakephp
src/Database/Driver.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Driver.php
MIT
public function disableAutoQuoting() { $this->_autoQuoting = false; return $this; }
Disable auto quoting of identifiers in queries. @return $this
disableAutoQuoting
php
cakephp/cakephp
src/Database/Driver.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Driver.php
MIT
public function __destruct() { if ($this->_transactionStarted && class_exists(Log::class)) { $message = 'The connection is going to be closed but there is an active transaction.'; $requestUrl = env('REQUEST_URI'); if ($requestUrl) { $message .= "\nRequest URL: " . $requestUrl; } $clientIp = env('REMOTE_ADDR'); if ($clientIp) { $message .= "\nClient IP: " . $clientIp; } Log::warning($message); } }
Destructor Disconnects the driver to release the connection.
__destruct
php
cakephp/cakephp
src/Database/Connection.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Connection.php
MIT
public function setSchemaCollection(SchemaCollectionInterface $collection) { $this->_schemaCollection = $collection; return $this; }
Sets a Schema\Collection object for this connection. @param \Cake\Database\Schema\CollectionInterface $collection The schema collection object @return $this
setSchemaCollection
php
cakephp/cakephp
src/Database/Connection.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Connection.php
MIT
public function enableSavePoints(bool $enable = true) { if ($enable === false) { $this->_useSavePoints = false; } else { $this->_useSavePoints = $this->getDriver()->supports(DriverFeatureEnum::SAVEPOINT); } return $this; }
Enables/disables the usage of savepoints, enables only if driver the allows it. If you are trying to enable this feature, make sure you check `isSavePointsEnabled()` to verify that savepoints were enabled successfully. @param bool $enable Whether save points should be used. @return $this
enableSavePoints
php
cakephp/cakephp
src/Database/Connection.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Connection.php
MIT
public function disableSavePoints() { $this->_useSavePoints = false; return $this; }
Disables the usage of savepoints. @return $this
disableSavePoints
php
cakephp/cakephp
src/Database/Connection.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Connection.php
MIT
public function setReturnType(string $type) { $this->_returnType = $type; return $this; }
Sets the type of the value this object will generate. @param string $type The name of the type that is to be returned @return $this
setReturnType
php
cakephp/cakephp
src/Database/TypedResultTrait.php
https://github.com/cakephp/cakephp/blob/master/src/Database/TypedResultTrait.php
MIT
public function setTypeMap(TypeMap|array $typeMap) { $this->_typeMap = is_array($typeMap) ? new TypeMap($typeMap) : $typeMap; return $this; }
Creates a new TypeMap if $typeMap is an array, otherwise exchanges it for the given one. @param \Cake\Database\TypeMap|array $typeMap Creates a TypeMap if array, otherwise sets the given TypeMap @return $this
setTypeMap
php
cakephp/cakephp
src/Database/TypeMapTrait.php
https://github.com/cakephp/cakephp/blob/master/src/Database/TypeMapTrait.php
MIT
public function setDefaultTypes(array $types) { $this->getTypeMap()->setDefaults($types); return $this; }
Overwrite the default type mappings for fields in the implementing object. This method is useful if you need to set type mappings that are shared across multiple functions/expressions in a query. To add a default without overwriting existing ones use `getTypeMap()->addDefaults()` @param array<int|string, string> $types The array of types to set. @return $this @see \Cake\Database\TypeMap::setDefaults()
setDefaultTypes
php
cakephp/cakephp
src/Database/TypeMapTrait.php
https://github.com/cakephp/cakephp/blob/master/src/Database/TypeMapTrait.php
MIT
public function update(ExpressionInterface|string $table) { $this->_dirty(); $this->_parts['update'][0] = $table; return $this; }
Create an update query. Can be combined with set() and where() methods to create update queries. @param \Cake\Database\ExpressionInterface|string $table The table you want to update. @return $this
update
php
cakephp/cakephp
src/Database/Query/UpdateQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/UpdateQuery.php
MIT
public function delete(?string $table = null) { $this->_dirty(); if ($table !== null) { $this->from($table); } return $this; }
Create a delete query. Can be combined with from(), where() and other methods to create delete queries with specific conditions. @param string|null $table The table to use when deleting. @return $this
delete
php
cakephp/cakephp
src/Database/Query/DeleteQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/DeleteQuery.php
MIT
public function having( ExpressionInterface|Closure|array|string|null $conditions = null, array $types = [], bool $overwrite = false, ) { if ($overwrite) { $this->_parts['having'] = $this->newExpr(); } $this->_conjugate('having', $conditions, 'AND', $types); return $this; }
Adds a condition or set of conditions to be used in the `HAVING` clause for this query. This method operates in exactly the same way as the method `where()` does. Please refer to its documentation for an insight on how to using each parameter. Having fields are not suitable for use with user supplied data as they are not sanitized by the query builder. @param \Cake\Database\ExpressionInterface|\Closure|array|string|null $conditions The having conditions. @param array<string, string> $types Associative array of type names used to bind values to query @param bool $overwrite whether to reset conditions with passed list or not @see \Cake\Database\Query::where() @return $this
having
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function andHaving(ExpressionInterface|Closure|array|string $conditions, array $types = []) { $this->_conjugate('having', $conditions, 'AND', $types); return $this; }
Connects any previously defined set of conditions to the provided list using the AND operator in the HAVING clause. This method operates in exactly the same way as the method `andWhere()` does. Please refer to its documentation for an insight on how to using each parameter. Having fields are not suitable for use with user supplied data as they are not sanitized by the query builder. @param \Cake\Database\ExpressionInterface|\Closure|array|string $conditions The AND conditions for HAVING. @param array<string, string> $types Associative array of type names used to bind values to query @see \Cake\Database\Query::andWhere() @return $this
andHaving
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function page(int $num, ?int $limit = null) { if ($num < 1) { throw new InvalidArgumentException('Pages must start at 1.'); } if ($limit !== null) { $this->limit($limit); } $limit = $this->clause('limit'); if ($limit === null) { $limit = 25; $this->limit($limit); } $offset = ($num - 1) * $limit; if (PHP_INT_MAX <= $offset) { $offset = PHP_INT_MAX; } $this->offset((int)$offset); return $this; }
Set the page of results you want. This method provides an easier to use interface to set the limit + offset in the record set you want as results. If empty the limit will default to the existing limit clause, and if that too is empty, then `25` will be used. Pages must start at 1. @param int $num The page number you want. @param int|null $limit The number of rows you want in the page. If null the current limit clause will be used. @return $this @throws \InvalidArgumentException If page number < 1.
page
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function enableBufferedResults() { $this->_dirty(); $this->bufferedResults = true; return $this; }
Enables buffered results. When enabled the results returned by this query will be buffered. This enables you to iterate a result set multiple times, or both cache and iterate it. When disabled it will consume less memory as fetched results are not remembered for future iterations. @return $this
enableBufferedResults
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function disableBufferedResults() { $this->_dirty(); $this->bufferedResults = false; return $this; }
Disables buffered results. Disabling buffering will consume less memory as fetched results are not remembered for future iterations. @return $this
disableBufferedResults
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function setSelectTypeMap(TypeMap|array $typeMap) { $this->_selectTypeMap = is_array($typeMap) ? new TypeMap($typeMap) : $typeMap; $this->_dirty(); return $this; }
Sets the TypeMap class where the types for each of the fields in the select clause are stored. @param \Cake\Database\TypeMap|array $typeMap Creates a TypeMap if array, otherwise sets the given TypeMap. @return $this
setSelectTypeMap
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function disableResultsCasting() { $this->typeCastEnabled = false; return $this; }
Disables result casting. When disabled, the fields will be returned as received from the database driver (which in most environments means they are being returned as strings), which can improve performance with larger datasets. @return $this
disableResultsCasting
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function enableResultsCasting() { $this->typeCastEnabled = true; return $this; }
Enables result casting. When enabled, the fields in the results returned by this Query will be cast to their corresponding PHP data type. @return $this
enableResultsCasting
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function useReadRole() { return $this->setConnectionRole(Connection::ROLE_READ); }
Sets the connection role to read. @return $this
useReadRole
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function useWriteRole() { return $this->setConnectionRole(Connection::ROLE_WRITE); }
Sets the connection role to write. @return $this
useWriteRole
php
cakephp/cakephp
src/Database/Query/SelectQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/SelectQuery.php
MIT
public function insert(array $columns, array $types = []) { if (!$columns) { throw new InvalidArgumentException('At least 1 column is required to perform an insert.'); } $this->_dirty(); $this->_parts['insert'][1] = $columns; if (!$this->_parts['values']) { $this->_parts['values'] = new ValuesExpression($columns, $this->getTypeMap()->setTypes($types)); } else { /** @var \Cake\Database\Expression\ValuesExpression $valuesExpr */ $valuesExpr = $this->_parts['values']; $valuesExpr->setColumns($columns); } return $this; }
Create an insert query. Note calling this method will reset any data previously set with Query::values(). @param array $columns The columns to insert into. @param array<int|string, string> $types A map between columns & their datatypes. @return $this @throws \InvalidArgumentException When there are 0 columns.
insert
php
cakephp/cakephp
src/Database/Query/InsertQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/InsertQuery.php
MIT
public function into(string $table) { $this->_dirty(); $this->_parts['insert'][0] = $table; return $this; }
Set the table name for insert queries. @param string $table The table name to insert into. @return $this
into
php
cakephp/cakephp
src/Database/Query/InsertQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/InsertQuery.php
MIT
public function values(ValuesExpression|Query|array $data) { if (empty($this->_parts['insert'])) { throw new DatabaseException( 'You cannot add values before defining columns to use.', ); } $this->_dirty(); if ($data instanceof ValuesExpression) { $this->_parts['values'] = $data; return $this; } /** @var \Cake\Database\Expression\ValuesExpression $valuesExpr */ $valuesExpr = $this->_parts['values']; $valuesExpr->add($data); return $this; }
Set the values for an insert query. Multi inserts can be performed by calling values() more than one time, or by providing an array of value sets. Additionally $data can be a Query instance to insert data from another SELECT statement. @param \Cake\Database\Expression\ValuesExpression|\Cake\Database\Query|array $data The data to insert. @return $this @throws \Cake\Database\Exception\DatabaseException if you try to set values before declaring columns. Or if you try to set values on non-insert queries.
values
php
cakephp/cakephp
src/Database/Query/InsertQuery.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Query/InsertQuery.php
MIT
public function useLocaleParser(bool $enable = true) { if ($enable === false) { $this->_useLocaleParser = $enable; return $this; } if ( static::$numberClass === Number::class || is_subclass_of(static::$numberClass, Number::class) ) { $this->_useLocaleParser = $enable; return $this; } throw new DatabaseException( sprintf('Cannot use locale parsing with the %s class', static::$numberClass), ); }
Sets whether to parse numbers passed to the marshal() function by using a locale aware parser. @param bool $enable Whether to enable @return $this @throws \Cake\Database\Exception\DatabaseException
useLocaleParser
php
cakephp/cakephp
src/Database/Type/DecimalType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DecimalType.php
MIT
public function setDatabaseTimezone(DateTimeZone|string|null $timezone) { if (is_string($timezone)) { $timezone = new DateTimeZone($timezone); } $this->dbTimezone = $timezone; return $this; }
Set database timezone. This is the time zone used when converting database strings to DateTime instances and converting DateTime instances to database strings. @see DateTimeType::setKeepDatabaseTimezone @param \DateTimeZone|string|null $timezone Database timezone. @return $this
setDatabaseTimezone
php
cakephp/cakephp
src/Database/Type/DateTimeType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DateTimeType.php
MIT
public function setUserTimezone(DateTimeZone|string|null $timezone) { if (is_string($timezone)) { $timezone = new DateTimeZone($timezone); } $this->userTimezone = $timezone; return $this; }
Set user timezone. This is the time zone used when marshaling strings to DateTime instances. @param \DateTimeZone|string|null $timezone User timezone. @return $this
setUserTimezone
php
cakephp/cakephp
src/Database/Type/DateTimeType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DateTimeType.php
MIT
public function setKeepDatabaseTimezone(bool $keep) { $this->keepDatabaseTimezone = $keep; return $this; }
Set whether DateTime object created from database string is converted to default time zone. If your database date times are in a specific time zone that you want to keep in the DateTime instance then set this to true. When false, datetime timezones are converted to default time zone. This is default behavior. @param bool $keep If true, database time zone is kept when converting to DateTime instances. @return $this
setKeepDatabaseTimezone
php
cakephp/cakephp
src/Database/Type/DateTimeType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DateTimeType.php
MIT
public function useLocaleParser(bool $enable = true) { if ($enable === false) { $this->_useLocaleMarshal = $enable; return $this; } if (is_a($this->_className, DateTime::class, true)) { $this->_useLocaleMarshal = $enable; return $this; } throw new DatabaseException( sprintf('Cannot use locale parsing with the %s class', $this->_className), ); }
Sets whether to parse strings passed to `marshal()` using the locale-aware format set by `setLocaleFormat()`. @param bool $enable Whether to enable @return $this
useLocaleParser
php
cakephp/cakephp
src/Database/Type/DateTimeType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DateTimeType.php
MIT
public function setLocaleFormat(array|string $format) { $this->_localeMarshalFormat = $format; return $this; }
Sets the locale-aware format used by `marshal()` when parsing strings. See `Cake\I18n\Time::parseDateTime()` for accepted formats. @param array|string $format The locale-aware format @see \Cake\I18n\Time::parseDateTime() @return $this
setLocaleFormat
php
cakephp/cakephp
src/Database/Type/DateTimeType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DateTimeType.php
MIT
public function setLocaleFormat(string|int|null $format) { $this->_localeMarshalFormat = $format; return $this; }
Sets the locale-aware format used by `marshal()` when parsing strings. See `Cake\I18n\Time::parseTime()` for accepted formats. @param string|int|null $format The locale-aware format @see \Cake\I18n\Time::parseTime() @return $this
setLocaleFormat
php
cakephp/cakephp
src/Database/Type/TimeType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/TimeType.php
MIT
public function setDecodingOptions(int $options) { $this->_decodingOptions = $options; return $this; }
Set json_decode() options. By default, the value is `JSON_OBJECT_AS_ARRAY`. @param int $options Decoding flags. Use JSON_* flags. Set `0` to reset. @return $this
setDecodingOptions
php
cakephp/cakephp
src/Database/Type/JsonType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/JsonType.php
MIT
public function setLocaleFormat(string|int $format) { $this->_localeMarshalFormat = $format; return $this; }
Sets the locale-aware format used by `marshal()` when parsing strings. See `Cake\I18n\Date::parseDate()` for accepted formats. @param string|int $format The locale-aware format @see \Cake\I18n\Date::parseDate() @return $this
setLocaleFormat
php
cakephp/cakephp
src/Database/Type/DateType.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Type/DateType.php
MIT
public function __clone() { if ($this->_field instanceof ExpressionInterface) { $this->_field = clone $this->_field; } }
Create a deep clone of the order clause. @return void
__clone
php
cakephp/cakephp
src/Database/Expression/OrderClauseExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/OrderClauseExpression.php
MIT
public function __clone() { foreach (['_field', '_from', '_to'] as $part) { if ($this->{$part} instanceof ExpressionInterface) { $this->{$part} = clone $this->{$part}; } } }
Do a deep clone of this expression. @return void
__clone
php
cakephp/cakephp
src/Database/Expression/BetweenExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/BetweenExpression.php
MIT
public function __clone() { $this->name = clone $this->name; foreach ($this->partitions as $i => $partition) { $this->partitions[$i] = clone $partition; } if ($this->order !== null) { $this->order = clone $this->order; } }
Clone this object and its subtree of expressions. @return void
__clone
php
cakephp/cakephp
src/Database/Expression/WindowExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/WindowExpression.php
MIT
public function name(string $name) { $this->name = new IdentifierExpression($name); return $this; }
Sets the name of this CTE. This is the named you used to reference the expression in select, insert, etc queries. @param string $name The CTE name. @return $this
name
php
cakephp/cakephp
src/Database/Expression/CommonTableExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CommonTableExpression.php
MIT
public function field(IdentifierExpression|array|string $fields) { $fields = (array)$fields; /** @var array<string|\Cake\Database\Expression\IdentifierExpression> $fields */ foreach ($fields as &$field) { if (!($field instanceof IdentifierExpression)) { $field = new IdentifierExpression($field); } } /** @var array<\Cake\Database\Expression\IdentifierExpression> $mergedFields */ $mergedFields = array_merge($this->fields, $fields); $this->fields = $mergedFields; return $this; }
Adds one or more fields (arguments) to the CTE. @param \Cake\Database\Expression\IdentifierExpression|array<string>|array<\Cake\Database\Expression\IdentifierExpression>|string $fields Field names @return $this
field
php
cakephp/cakephp
src/Database/Expression/CommonTableExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CommonTableExpression.php
MIT
public function materialized() { $this->materialized = 'MATERIALIZED'; return $this; }
Sets this CTE as materialized. @return $this
materialized
php
cakephp/cakephp
src/Database/Expression/CommonTableExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CommonTableExpression.php
MIT
public function notMaterialized() { $this->materialized = 'NOT MATERIALIZED'; return $this; }
Sets this CTE as not materialized. @return $this
notMaterialized
php
cakephp/cakephp
src/Database/Expression/CommonTableExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CommonTableExpression.php
MIT
public function __clone() { $this->name = clone $this->name; if ($this->query) { $this->query = clone $this->query; } foreach ($this->fields as $key => $field) { $this->fields[$key] = clone $field; } }
Clones the inner expression objects. @return void
__clone
php
cakephp/cakephp
src/Database/Expression/CommonTableExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CommonTableExpression.php
MIT
public function __construct(mixed $value = null, ?string $type = null) { if (func_num_args() > 0) { if ( $value !== null && !is_scalar($value) && !(is_object($value) && !($value instanceof Closure)) ) { throw new InvalidArgumentException(sprintf( 'The `$value` argument must be either `null`, a scalar value, an object, ' . 'or an instance of `\%s`, `%s` given.', ExpressionInterface::class, get_debug_type($value), )); } $this->value = $value; if ( $value !== null && $type === null && !($value instanceof ExpressionInterface) ) { $type = $this->inferType($value); } $this->valueType = $type; $this->isSimpleVariant = true; } }
Constructor. When a value is set, the syntax generated is `CASE case_value WHEN when_value ... END` (simple case), where the `when_value`'s are compared against the `case_value`. When no value is set, the syntax generated is `CASE WHEN when_conditions ... END` (searched case), where the conditions hold the comparisons. Note that `null` is a valid case value, and thus should only be passed if you actually want to create the simple case expression variant! @param \Cake\Database\ExpressionInterface|object|scalar|null $value The case value. @param string|null $type The case value type. If no type is provided, the type will be tried to be inferred from the value.
__construct
php
cakephp/cakephp
src/Database/Expression/CaseStatementExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CaseStatementExpression.php
MIT
public function else(mixed $result, ?string $type = null) { if ($this->whenBuffer !== null) { throw new LogicException('Cannot call `else()` between `when()` and `then()`.'); } if ( $result !== null && !is_scalar($result) && !(is_object($result) && !($result instanceof Closure)) ) { throw new InvalidArgumentException(sprintf( 'The `$result` argument must be either `null`, a scalar value, an object, ' . 'or an instance of `\%s`, `%s` given.', ExpressionInterface::class, get_debug_type($result), )); } $type ??= $this->inferType($result); $this->else = $result; $this->elseType = $type; return $this; }
Sets the `ELSE` result value. @param \Cake\Database\ExpressionInterface|object|scalar|null $result The result value. @param string|null $type The result type. If no type is provided, the type will be tried to be inferred from the value. @return $this @throws \LogicException In case a closing `then()` call is required before calling this method. @throws \InvalidArgumentException In case the `$result` argument is neither a scalar value, nor an object, an instance of `\Cake\Database\ExpressionInterface`, or `null`.
else
php
cakephp/cakephp
src/Database/Expression/CaseStatementExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CaseStatementExpression.php
MIT
public function setReturnType(string $type) { $this->returnType = $type; return $this; }
Sets the abstract type that this expression will return. If no type is being explicitly set via this method, then the `getReturnType()` method will try to infer the type from the result types of the `then()` and `else() `calls. @param string $type The type name to use. @return $this
setReturnType
php
cakephp/cakephp
src/Database/Expression/CaseStatementExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/CaseStatementExpression.php
MIT
public function __construct( ExpressionInterface|array|string $fields, ExpressionInterface|array $values, array $types = [], string $conjunction = '=', ) { $this->types = $types; $this->setField($fields); $this->_operator = $conjunction; $this->setValue($values); }
Constructor @param \Cake\Database\ExpressionInterface|array|string $fields the fields to use to form a tuple @param \Cake\Database\ExpressionInterface|array $values the values to use to form a tuple @param array<string|null> $types the types names to use for casting each of the values, only one type per position in the value array in needed @param string $conjunction the operator used for comparing field and value
__construct
php
cakephp/cakephp
src/Database/Expression/TupleComparison.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/TupleComparison.php
MIT
public function setColumns(array $columns) { $this->_columns = $columns; $this->_castedExpressions = false; return $this; }
Sets the columns to be inserted. @param array $columns Array with columns to be inserted. @return $this
setColumns
php
cakephp/cakephp
src/Database/Expression/ValuesExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/ValuesExpression.php
MIT
public function setValues(array $values) { $this->_values = $values; $this->_castedExpressions = false; return $this; }
Sets the values to be inserted. @param array $values Array with values to be inserted. @return $this
setValues
php
cakephp/cakephp
src/Database/Expression/ValuesExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/ValuesExpression.php
MIT
public function setQuery(Query $query) { $this->_query = $query; return $this; }
Sets the query object to be used as the values expression to be evaluated to insert records in the table. @param \Cake\Database\Query $query The query to set @return $this
setQuery
php
cakephp/cakephp
src/Database/Expression/ValuesExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/ValuesExpression.php
MIT
public function __construct( ExpressionInterface|array|string $conditions = [], TypeMap|array $types = [], string $conjunction = 'AND', ) { $this->setTypeMap($types); $this->setConjunction(strtoupper($conjunction)); if ($conditions) { $this->add($conditions, $this->getTypeMap()->getTypes()); } }
Constructor. A new expression object can be created without any params and be built dynamically. Otherwise, it is possible to pass an array of conditions containing either a tree-like array structure to be parsed and/or other expression objects. Optionally, you can set the conjunction keyword to be used for joining each part of this level of the expression tree. @param \Cake\Database\ExpressionInterface|array|string $conditions Tree like array structure containing all the conditions to be added or nested inside this expression object. @param \Cake\Database\TypeMap|array $types Associative array of types to be associated with the values passed in $conditions. @param string $conjunction the glue that will join all the string conditions at this level of the expression tree. For example "AND", "OR", "XOR"... @see \Cake\Database\Expression\QueryExpression::add() for more details on $conditions and $types
__construct
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function setConjunction(string $conjunction) { $this->_conjunction = strtoupper($conjunction); return $this; }
Changes the conjunction for the conditions at this level of the expression tree. @param string $conjunction Value to be used for joining conditions @return $this
setConjunction
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function add(ExpressionInterface|array|string $conditions, array $types = []) { if (is_string($conditions) || $conditions instanceof ExpressionInterface) { $this->_conditions[] = $conditions; return $this; } $this->_addConditions($conditions, $types); return $this; }
Adds one or more conditions to this expression object. Conditions can be expressed in a one dimensional array, that will cause all conditions to be added directly at this level of the tree or they can be nested arbitrarily making it create more expression objects that will be nested inside and configured to use the specified conjunction. If the type passed for any of the fields is expressed "type[]" (note braces) then it will cause the placeholder to be re-written dynamically so if the value is an array, it will create as many placeholders as values are in it. @param \Cake\Database\ExpressionInterface|array|string $conditions single or multiple conditions to be added. When using an array and the key is 'OR' or 'AND' a new expression object will be created with that conjunction and internal array value passed as conditions. @param array<int|string, string> $types Associative array of fields pointing to the type of the values that are being passed. Used for correctly binding values to statements. @see \Cake\Database\Query::where() for examples on conditions @return $this
add
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function eq(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, '=')); }
Adds a new condition to the expression object in the form "field = value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. If it is suffixed with "[]" and the value is an array then multiple placeholders will be created, one per each value in the array. @return $this
eq
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function notEq(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, '!=')); }
Adds a new condition to the expression object in the form "field != value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. If it is suffixed with "[]" and the value is an array then multiple placeholders will be created, one per each value in the array. @return $this
notEq
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function gt(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, '>')); }
Adds a new condition to the expression object in the form "field > value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
gt
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function lt(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, '<')); }
Adds a new condition to the expression object in the form "field < value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
lt
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function gte(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, '>=')); }
Adds a new condition to the expression object in the form "field >= value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
gte
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function lte(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, '<=')); }
Adds a new condition to the expression object in the form "field <= value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
lte
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function isNull(ExpressionInterface|string $field) { if (!($field instanceof ExpressionInterface)) { $field = new IdentifierExpression($field); } return $this->add(new UnaryExpression('IS NULL', $field, UnaryExpression::POSTFIX)); }
Adds a new condition to the expression object in the form "field IS NULL". @param \Cake\Database\ExpressionInterface|string $field database field to be tested for null @return $this
isNull
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function isNotNull(ExpressionInterface|string $field) { if (!($field instanceof ExpressionInterface)) { $field = new IdentifierExpression($field); } return $this->add(new UnaryExpression('IS NOT NULL', $field, UnaryExpression::POSTFIX)); }
Adds a new condition to the expression object in the form "field IS NOT NULL". @param \Cake\Database\ExpressionInterface|string $field database field to be tested for not null @return $this
isNotNull
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function like(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, 'LIKE')); }
Adds a new condition to the expression object in the form "field LIKE value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
like
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function notLike(ExpressionInterface|string $field, mixed $value, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new ComparisonExpression($field, $value, $type, 'NOT LIKE')); }
Adds a new condition to the expression object in the form "field NOT LIKE value". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param mixed $value The value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
notLike
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function in( ExpressionInterface|string $field, ExpressionInterface|array|string $values, ?string $type = null, ) { $type ??= $this->_calculateType($field); $type = $type ?: 'string'; $type .= '[]'; $values = $values instanceof ExpressionInterface ? $values : (array)$values; return $this->add(new ComparisonExpression($field, $values, $type, 'IN')); }
Adds a new condition to the expression object in the form "field IN (value1, value2)". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param \Cake\Database\ExpressionInterface|array|string $values the value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
in
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function notIn( ExpressionInterface|string $field, ExpressionInterface|array|string $values, ?string $type = null, ) { $type ??= $this->_calculateType($field); $type = $type ?: 'string'; $type .= '[]'; $values = $values instanceof ExpressionInterface ? $values : (array)$values; return $this->add(new ComparisonExpression($field, $values, $type, 'NOT IN')); }
Adds a new condition to the expression object in the form "field NOT IN (value1, value2)". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param \Cake\Database\ExpressionInterface|array|string $values the value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
notIn
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function notInOrNull( ExpressionInterface|string $field, ExpressionInterface|array|string $values, ?string $type = null, ) { $or = new static([], [], 'OR'); $or ->notIn($field, $values, $type) ->isNull($field); return $this->add($or); }
Adds a new condition to the expression object in the form "(field NOT IN (value1, value2) OR field IS NULL". @param \Cake\Database\ExpressionInterface|string $field Database field to be compared against value @param \Cake\Database\ExpressionInterface|array|string $values the value to be bound to $field for comparison @param string|null $type the type name for $value as configured using the Type map. @return $this
notInOrNull
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function exists(ExpressionInterface $expression) { return $this->add(new UnaryExpression('EXISTS', $expression, UnaryExpression::PREFIX)); }
Adds a new condition to the expression object in the form "EXISTS (...)". @param \Cake\Database\ExpressionInterface $expression the inner query @return $this
exists
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function notExists(ExpressionInterface $expression) { return $this->add(new UnaryExpression('NOT EXISTS', $expression, UnaryExpression::PREFIX)); }
Adds a new condition to the expression object in the form "NOT EXISTS (...)". @param \Cake\Database\ExpressionInterface $expression the inner query @return $this
notExists
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function between(ExpressionInterface|string $field, mixed $from, mixed $to, ?string $type = null) { $type ??= $this->_calculateType($field); return $this->add(new BetweenExpression($field, $from, $to, $type)); }
Adds a new condition to the expression object in the form "field BETWEEN from AND to". @param \Cake\Database\ExpressionInterface|string $field The field name to compare for values in between the range. @param mixed $from The initial value of the range. @param mixed $to The ending value in the comparison range. @param string|null $type the type name for $value as configured using the Type map. @return $this
between
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function not(ExpressionInterface|Closure|array|string $conditions, array $types = []) { return $this->add(['NOT' => $conditions], $types); }
Adds a new set of conditions to this level of the tree and negates the final result by prepending a NOT, it will look like "NOT ( (condition1) AND (conditions2) )" conjunction depends on the one currently configured for this object. @param \Cake\Database\ExpressionInterface|\Closure|array|string $conditions to be added and negated @param array<string, string> $types Associative array of fields pointing to the type of the values that are being passed. Used for correctly binding values to statements. @return $this
not
php
cakephp/cakephp
src/Database/Expression/QueryExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/QueryExpression.php
MIT
public function when(object|array|string|float|int|bool $when, array|string|null $type = null) { if (is_array($when)) { if (!$when) { throw new InvalidArgumentException('The `$when` argument must be a non-empty array'); } if ( $type !== null && !is_array($type) ) { throw new InvalidArgumentException(sprintf( 'When using an array for the `$when` argument, the `$type` argument must be an ' . 'array too, `%s` given.', get_debug_type($type), )); } // avoid dirtying the type map for possible consecutive `when()` calls $typeMap = clone $this->_typeMap; if ( is_array($type) && $type !== [] ) { $typeMap = $typeMap->setTypes($type); } $when = new QueryExpression($when, $typeMap); } else { if ( $type !== null && !is_string($type) ) { throw new InvalidArgumentException(sprintf( 'When using a non-array value for the `$when` argument, the `$type` argument must ' . 'be a string, `%s` given.', get_debug_type($type), )); } if ( $type === null && !($when instanceof ExpressionInterface) ) { $type = $this->inferType($when); } } $this->when = $when; $this->whenType = $type; return $this; }
Sets the `WHEN` value. @param object|array|string|float|int|bool $when The `WHEN` value. When using an array of conditions, it must be compatible with `\Cake\Database\Query::where()`. Note that this argument is _not_ completely safe for use with user data, as a user supplied array would allow for raw SQL to slip in! If you plan to use user data, either pass a single type for the `$type` argument (which forces the `$when` value to be a non-array, and then always binds the data), use a conditions array where the user data is only passed on the value side of the array entries, or custom bindings! @param array<string, string>|string|null $type The when value type. Either an associative array when using array style conditions, or else a string. If no type is provided, the type will be tried to be inferred from the value. @return $this @throws \InvalidArgumentException In case the `$when` argument is an empty array. @throws \InvalidArgumentException In case the `$when` argument is an array, and the `$type` argument is neither an array, nor null. @throws \InvalidArgumentException In case the `$when` argument is a non-array value, and the `$type` argument is neither a string, nor null. @see CaseStatementExpression::when() for a more detailed usage explanation.
when
php
cakephp/cakephp
src/Database/Expression/WhenThenExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/WhenThenExpression.php
MIT
public function then(mixed $result, ?string $type = null) { if ( $result !== null && !is_scalar($result) && !(is_object($result) && !($result instanceof Closure)) ) { throw new InvalidArgumentException(sprintf( 'The `$result` argument must be either `null`, a scalar value, an object, ' . 'or an instance of `\%s`, `%s` given.', ExpressionInterface::class, get_debug_type($result), )); } $this->then = $result; $this->thenType = $type ?? $this->inferType($result); $this->hasThenBeenDefined = true; return $this; }
Sets the `THEN` result value. @param \Cake\Database\ExpressionInterface|object|scalar|null $result The result value. @param string|null $type The result type. If no type is provided, the type will be inferred from the given result value. @return $this
then
php
cakephp/cakephp
src/Database/Expression/WhenThenExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/WhenThenExpression.php
MIT
public function __construct(string $name, array $params = [], array $types = [], string $returnType = 'string') { $this->_name = $name; $this->_returnType = $returnType; parent::__construct($params, $types, ','); }
Constructor. Takes a name for the function to be invoked and a list of params to be passed into the function. Optionally you can pass a list of types to be used for each bound param. By default, all params that are passed will be quoted. If you wish to use literal arguments, you need to explicitly hint this function. ### Examples: `$f = new FunctionExpression('CONCAT', ['CakePHP', ' rules']);` Previous line will generate `CONCAT('CakePHP', ' rules')` `$f = new FunctionExpression('CONCAT', ['name' => 'literal', ' rules']);` Will produce `CONCAT(name, ' rules')` @param string $name the name of the function to be constructed @param array $params list of arguments to be passed to the function If associative the key would be used as argument when value is 'literal' @param array<string, string>|array<string|null> $types Associative array of types to be associated with the passed arguments @param string $returnType The return type of this expression
__construct
php
cakephp/cakephp
src/Database/Expression/FunctionExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/FunctionExpression.php
MIT
public function setName(string $name) { $this->_name = $name; return $this; }
Sets the name of the SQL function to be invoke in this expression. @param string $name The name of the function @return $this
setName
php
cakephp/cakephp
src/Database/Expression/FunctionExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/FunctionExpression.php
MIT
public function filter(ExpressionInterface|Closure|array|string $conditions, array $types = []) { $this->filter ??= new QueryExpression(); if ($conditions instanceof Closure) { $conditions = $conditions(new QueryExpression()); } $this->filter->add($conditions, $types); return $this; }
Adds conditions to the FILTER clause. The conditions are the same format as `Query::where()`. @param \Cake\Database\ExpressionInterface|\Closure|array|string $conditions The conditions to filter on. @param array<string, string> $types Associative array of type names used to bind values to query @return $this @see \Cake\Database\Query::where()
filter
php
cakephp/cakephp
src/Database/Expression/AggregateExpression.php
https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/AggregateExpression.php
MIT