CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • Connection
  • Driver
  • FieldTypeConverter
  • FunctionsBuilder
  • Query
  • SchemaCache
  • Type
  • TypeMap

Interfaces

  • DriverInterface
  • ExpressionInterface
  • StatementInterface
  • TypedResultInterface
  • TypeInterface

Traits

  • SqlDialectTrait
  • TypeConverterTrait
  • TypedResultTrait
  • TypeMapTrait

Exceptions

  • Exception

Class TypeMap

Implements default and single-use mappings for columns to their associated types

Namespace: Cake\Database
Location: Database/TypeMap.php

Properties summary

  • $_defaults protected
    string[]
    Associative array with the default fields and the related types this query might contain.
  • $_types protected
    string[]
    Associative array with the fields and the related types that override defaults this query might contain

Method Summary

  • __construct() public
    Creates an instance with the given defaults
  • addDefaults() public
    Add additional default types into the type map.
  • defaults() public deprecated

    Configures a map of default fields and their associated types to be used as the default list of types for every function in this class with a $types param. Useful to avoid repetition when calling the same functions using the same fields and types.

  • getDefaults() public
    Returns the currently configured types.
  • getTypes() public
    Gets a map of fields and their associated types for single-use.
  • setDefaults() public
    Configures a map of fields and associated type.
  • setTypes() public
    Sets a map of fields and their associated types for single-use.
  • toArray() public
    Returns an array of all types mapped types
  • type() public

    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.

  • types() public deprecated
    Sets a map of fields and their associated types for single-use.

Method Detail

__construct() public ¶

__construct( array $defaults = [] )

Creates an instance with the given defaults

Parameters
array $defaults optional []
The defaults to use.

addDefaults() public ¶

addDefaults( array $types )

Add additional default types into the type map.

If a key already exists it will not be overwritten.

Parameters
array $types
The additional types to add.

defaults() public deprecated ¶

defaults( array $defaults = null )

Configures a map of default fields and their associated types to be used as the default list of types for every function in this class with a $types param. Useful to avoid repetition when calling the same functions using the same fields and types.

If called with no arguments it will return the currently configured types.

Example

$query->defaults(['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()

Deprecated
3.4.0 Use setDefaults()/getDefaults() instead.
Parameters
array $defaults optional null

associative array where keys are field names and values are the correspondent type.

Returns

$this|array

getDefaults() public ¶

getDefaults( )

Returns the currently configured types.

Returns
string[]

getTypes() public ¶

getTypes( )

Gets a map of fields and their associated types for single-use.

Returns
string[]

setDefaults() public ¶

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.

Example

$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().

Parameters
array $defaults

Associative array where keys are field names and values are the correspondent type.

Returns

$this

setTypes() public ¶

setTypes( array $types )

Sets a map of fields and their associated types for single-use.

Example

$query->setTypes(['created' => 'time']);

This method will replace all the existing type maps with the ones provided.

Parameters
array $types

Associative array where keys are field names and values are the correspondent type.

Returns

$this

toArray() public ¶

toArray( )

Returns an array of all types mapped types

Returns
string[]

type() public ¶

type( string $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.

Parameters
string $column
The type for a given column
Returns
string|null

types() public deprecated ¶

types( array $types = null )

Sets a map of fields and their associated types for single-use.

If called with no arguments it will return the currently configured types.

Example

$query->types(['created' => 'time']);

This method will replace all the existing type maps with the ones provided.

Deprecated
3.4.0 Use setTypes()/getTypes() instead.
Parameters
array $types optional null

associative array where keys are field names and values are the correspondent type.

Returns

$this|array

Properties detail

$_defaults ¶

protected string[]

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.

$_types ¶

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

[]
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs