\Lqdt\OrmJson\Model\BehaviorJsonBehavior

This CakePHP behavior adds support to performs mysql queries into JSON fields

The behavior adds a custom finder Model::find('json') that returns a JsonQuery instance

You can use any construct similar to classic query building based on field/value array or full query string. The array form automatically escape string type parameters.

JSON field name must be called in specific format like this : tt>path@[Model.]field and they will be turned into JSON_EXTRACT short notation like [Model.]fieldname->"$.path"

Summary

Methods
Properties
Constants
jsonQuery()
findJson()
beforeMarshal()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

jsonQuery()

jsonQuery(\Cake\ORM\Query  $parentQuery = null) : \Lqdt\OrmJson\ORM\JsonQuery

Create a JsonQuery from existing Gquery object or from scratch

Parameters

\Cake\ORM\Query $parentQuery

Existing query

Returns

\Lqdt\OrmJson\ORM\JsonQuery

JsonQuery instance

findJson()

findJson(\Cake\ORM\Query  $query, array  $options) : \Lqdt\OrmJson\ORM\JsonQuery

Custom finder Model::find('json') that lets use JSON inner field key selector and JSON inner field key/value set for WHERE clause

Parameters

\Cake\ORM\Query $query

CakePHP Query Object

array $options

Options for the finder
$options = [
'json.fields' => (array|string) Fields/key of JSON type
'json.conditions' => (array|string) Conditions to use in WHERE clause
'json.sort' => (array|string) Condition to use in ORDER BY clause ...
]

Returns

\Lqdt\OrmJson\ORM\JsonQuery

Cunstom JsonQuery instance

beforeMarshal()

beforeMarshal(\Cake\Event\Event  $event, \ArrayObject  $data, \ArrayObject  $options) : void

Parse datfield from raw data used in newEntity or PatchEntity methods into nested array values

When using patchEntity, a call to jsonMerge must be done to merge old and new values or new data will simply replaces previous one in the JSON field.

Parameters

\Cake\Event\Event $event

Event

\ArrayObject $data

Data

\ArrayObject $options

Options