Implements default and single-use mappings for columns to their associated types
string[]
Associative array with the default fields and the related types this query might contain.
string[]
Associative array with the fields and the related types that override defaults this query might contain
Returns the type of the given column. If there is no single use type is configured, the column type will be looked for inside the default mapping. If neither exist, null will be returned.
__construct(array $defaults)
Creates an instance with the given defaults
string[]
$defaults optional The defaults to use.
addDefaults(array $types)
Add additional default types into the type map.
If a key already exists it will not be overwritten.
string[]
$types The additional types to add.
getDefaults()
Returns the currently configured types.
string[]
getTypes()
Gets a map of fields and their associated types for single-use.
string[]
setDefaults(array $defaults)
Configures a map of fields and associated type.
These values will be used as the default mapping of types for every function in this instance that supports a $types
param.
This method is useful when you want to avoid repeating type definitions as setting types overwrites the last set of types.
$query->setDefaults(['created' => 'datetime', 'is_visible' => 'boolean']);
This method will replace all the existing default mappings with the ones provided. To add into the mappings use addDefaults()
.
string[]
$defaults Associative array where keys are field names and values are the correspondent type.
$this
setTypes(array $types)
Sets a map of fields and their associated types for single-use.
$query->setTypes(['created' => 'time']);
This method will replace all the existing type maps with the ones provided.
string[]
$types Associative array where keys are field names and values are the correspondent type.
$this
toArray()
Returns an array of all types mapped types
string[]
type(mixed $column)
Returns the type of the given column. If there is no single use type is configured, the column type will be looked for inside the default mapping. If neither exist, null will be returned.
string|int
$column The type for a given column
string|null
Associative array with the default fields and the related types this query might contain.
Used to avoid repetition when calling multiple functions inside this class that may require a custom type for a specific field.
string[]
Associative array with the fields and the related types that override defaults this query might contain
Used to avoid repetition when calling multiple functions inside this class that may require a custom type for a specific field.
string[]
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.Database.TypeMap.html