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 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 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
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
      • Driver
      • Exception
      • Expression
      • Log
      • Query
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class JsonPathExpression

Represents a JSON path expression with optional clauses for each json function.

Namespace: Cake\Database\Expression

Constants

  • ALLOWED_BEHAVIORS ¶
    [self::BEHAVIOR_NULL, self::BEHAVIOR_ERROR, self::BEHAVIOR_DEFAULT, self::BEHAVIOR_UNKNOWN, self::BEHAVIOR_TRUE, self::BEHAVIOR_FALSE]
  • BEHAVIOR_DEFAULT ¶
    'DEFAULT'
  • BEHAVIOR_ERROR ¶
    'ERROR'
  • BEHAVIOR_FALSE ¶
    'FALSE'
  • BEHAVIOR_NULL ¶
    'NULL'
  • BEHAVIOR_TRUE ¶
    'TRUE'
  • BEHAVIOR_UNKNOWN ¶
    'UNKNOWN'

Property Summary

  • $onEmpty protected
    array{behavior: string, value: mixed}|null
  • $onError protected
    array{behavior: string, value: mixed}|null
  • $passing protected
    array<string, array{value: mixed, type: (string|int|null)}>
  • $returnType protected
    string

    The type name this expression will return when executed

  • $returning protected
    string|null

Method Summary

  • __construct() public

    Constructs with base json path string.

  • behaviorSql() protected

    Generates the SQL for ON EMPTY or ON ERROR clauses.

  • buildBehavior() protected

    Validate and build behavior config.

  • getReturnType() public

    Gets the type of the value this object will generate.

  • inferType() protected

    Infers the abstract type for the given value.

  • onEmpty() public

    Sets the ON EMPTY clause.

    Not all database engines support every clause. Check for support before using.

  • onError() public

    Sets the ON ERROR clause.

    Not all database engines support every clause. Check for support before using.

  • passing() public

    Sets the PASSING clause.

    SQL Injection Warning: PASSING names are not sanitized before use.

    Not all database engines support every clause. Check for support before using.

  • returning() public

    Sets the RETURNING clause.

    SQL Injection Warning: RETURNING type is not sanitized before use.

    Not all database engines support every clause. Check for support before using.

  • setReturnType() public

    Sets the type of the value this object will generate.

  • sql() public

    Converts the Node into a SQL string fragment.

  • traverse() public

    Iterates over each part of the expression recursively for every level of the expressions tree and executes the callback, passing as first parameter the instance of the expression currently being iterated.

Method Detail

__construct() ¶ public

__construct(string $path)

Constructs with base json path string.

Parameters
string $path

The json path

behaviorSql() ¶ protected

behaviorSql(string $origin, array $config, Cake\Database\ValueBinder $binder): string

Generates the SQL for ON EMPTY or ON ERROR clauses.

Parameters
string $origin

The behavior origin.

array $config

The behavior config.

Cake\Database\ValueBinder $binder

The value binder.

Returns
string

buildBehavior() ¶ protected

buildBehavior(string $behavior, mixed $value): array{behavior: string, value: mixed}

Validate and build behavior config.

Parameters
string $behavior

The behavior name.

mixed $value

The value if behavior is DEFAULT.

Returns
array{behavior: string, value: mixed}

getReturnType() ¶ public

getReturnType(): string

Gets the type of the value this object will generate.

Returns
string

inferType() ¶ protected

inferType(mixed $value, Cake\Database\TypeMap|null $typeMap = null): string|null

Infers the abstract type for the given value.

Parameters
mixed $value

The value for which to infer the type.

Cake\Database\TypeMap|null $typeMap optional

Used to resolve the type of identifier expressions.

Returns
string|null

The abstract type, or null if it could not be inferred.

onEmpty() ¶ public

onEmpty(self::BEHAVIOR_* $behavior, mixed $value = null): $this

Sets the ON EMPTY clause.

Not all database engines support every clause. Check for support before using.

Parameters
self::BEHAVIOR_* $behavior

The behavior on empty (NULL, ERROR, or DEFAULT).

mixed $value optional

The value if behavior is DEFAULT.

Returns
$this

onError() ¶ public

onError(self::BEHAVIOR_* $behavior, mixed $value = null): $this

Sets the ON ERROR clause.

Not all database engines support every clause. Check for support before using.

Parameters
self::BEHAVIOR_* $behavior

The behavior on error (NULL, ERROR, or DEFAULT).

mixed $value optional

The value if behavior is DEFAULT.

Returns
$this

passing() ¶ public

passing(array<string, string|int|float|bool> $passing, array<string, string|int> $types = []): $this

Sets the PASSING clause.

SQL Injection Warning: PASSING names are not sanitized before use.

Not all database engines support every clause. Check for support before using.

Parameters
array<string, string|int|float|bool> $passing

Mapping of variable name to value.

array<string, string|int> $types optional

Optional mapping of variable name to binding type.

Returns
$this

returning() ¶ public

returning(string $type): $this

Sets the RETURNING clause.

SQL Injection Warning: RETURNING type is not sanitized before use.

Not all database engines support every clause. Check for support before using.

Parameters
string $type

The sql data type to return

Returns
$this

setReturnType() ¶ public

setReturnType(string $type): $this

Sets the type of the value this object will generate.

Parameters
string $type

The name of the type that is to be returned

Returns
$this

sql() ¶ public

sql(Cake\Database\ValueBinder $binder): string

Converts the Node into a SQL string fragment.

Parameters
Cake\Database\ValueBinder $binder
Returns
string

traverse() ¶ public

traverse(Closure $callback): $this

Iterates over each part of the expression recursively for every level of the expressions tree and executes the callback, passing as first parameter the instance of the expression currently being iterated.

Parameters
Closure $callback
Returns
$this

Property Detail

$onEmpty ¶ protected

Type
array{behavior: string, value: mixed}|null

$onError ¶ protected

Type
array{behavior: string, value: mixed}|null

$passing ¶ protected

Type
array<string, array{value: mixed, type: (string|int|null)}>

$returnType ¶ protected

The type name this expression will return when executed

Type
string

$returning ¶ protected

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