Fr3nch13/CakePHP Utilities

TypeConverterTrait

Type converter trait

Table of Contents

Methods

cast()  : array<string|int, mixed>
Converts a give value to a suitable database value based on type and return relevant internal statement type
matchTypes()  : array<string|int, mixed>
Matches columns to corresponding types

Methods

cast()

Converts a give value to a suitable database value based on type and return relevant internal statement type

public cast(mixed $value[, TypeInterface|string|int $type = 'string' ]) : array<string|int, mixed>
Parameters
$value : mixed

The value to cast

$type : TypeInterface|string|int = 'string'

The type name or type instance to use.

Tags
pslam-return

array{mixed, int}

Return values
array<string|int, mixed>

list containing converted value and internal type

matchTypes()

Matches columns to corresponding types

public matchTypes(array<string|int, mixed> $columns, array<string|int, mixed> $types) : array<string|int, mixed>

Both $columns and $types should either be numeric based or string key based at the same time.

Parameters
$columns : array<string|int, mixed>

list or associative array of columns and parameters to be bound with types

$types : array<string|int, mixed>

list or associative array of types

Return values
array<string|int, mixed>

        
On this page

Search results