Class ValueBinder

Value binder class manages list of values bound to conditions.

Namespace: Cake\Database

Properties summary

  • $_bindings protected
    array

    Array containing a list of bound values to the conditions on this object. Each array entry is another array structure containing the actual bound value, its type and the placeholder it is bound to.

  • $_bindingsCount protected
    int

    A counter of the number of parameters bound in this expression object

Method Summary

  • attachTo() public

    Binds all the stored values in this object to the passed statement.

  • bind() public

    Associates a query placeholder to a value and a type

  • bindings() public

    Returns all values bound to this expression object at this nesting level.

  • generateManyNamed() public

    Creates unique named placeholders for each of the passed values and binds them with the specified type.

  • placeholder() public

    Creates a unique placeholder name if the token provided does not start with ":" otherwise, it will return the same string and internally increment the number of placeholders generated by this object.

  • reset() public

    Clears any bindings that were previously registered

  • resetCount() public

    Resets the bindings count without clearing previously bound values

Method Detail

attachTo() public

attachTo(\Cake\Database\StatementInterface $statement)

Binds all the stored values in this object to the passed statement.

Parameters

\Cake\Database\StatementInterface $statement

The statement to add parameters to.

bind() public

bind(mixed $param, mixed $value, mixed $type)

Associates a query placeholder to a value and a type

Parameters

string|int $param

placeholder to be replaced with quoted version of $value

mixed $value

The value to be bound

string|int|null $type optional

the mapped type name, used for casting when sending to database

bindings() public

bindings()

Returns all values bound to this expression object at this nesting level.

Subexpression bound values will not be returned with this function.

Returns

array

generateManyNamed() public

generateManyNamed(iterable $values, mixed $type)

Creates unique named placeholders for each of the passed values and binds them with the specified type.

Parameters

iterable $values

The list of values to be bound

string|int|null $type optional

The type with which all values will be bound

Returns

array

with the placeholders to insert in the query

placeholder() public

placeholder(string $token)

Creates a unique placeholder name if the token provided does not start with ":" otherwise, it will return the same string and internally increment the number of placeholders generated by this object.

Parameters

string $token

string from which the placeholder will be derived from, if it starts with a colon, then the same string is returned

Returns

string

to be used as a placeholder in a query expression

reset() public

reset()

Clears any bindings that were previously registered

resetCount() public

resetCount()

Resets the bindings count without clearing previously bound values

Property Detail

$_bindings protected

Array containing a list of bound values to the conditions on this object. Each array entry is another array structure containing the actual bound value, its type and the placeholder it is bound to.

Type

array

$_bindingsCount protected

A counter of the number of parameters bound in this expression object

Type

int

© 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.ValueBinder.html