CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.1 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.1
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 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

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
      • Dialect
      • Driver
      • Exception
      • Expression
      • Log
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class TypeMap

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

Namespace: Cake\Database

Property Summary

  • $_defaults protected
    array

    Associative array with the default fields and the related types this query might contain.

  • $_types protected
    array

    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

    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.

  • 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

    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): void

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.

Returns
void

defaults() ¶ public

defaults(array $defaults = null): $this|array

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 type maps with the ones provided.

Parameters
array $defaults optional

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

Returns
$this|array

type() ¶ public

type(string $column): null|string

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
null|string

types() ¶ public

types(array $types = null): $this|array

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.

Parameters
array $types optional

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

Returns
$this|array

Property Detail

$_defaults ¶ protected

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.

Type
array

$_types ¶ protected

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.

Type
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs