The JSON properties plugin allows you to easily add structured data to a single database table field. You can easily store arrays and structures without the need for extra tables in your model.
The JSON properties plugin has a single initialization method that you must call in your model's init()
.
- jsonProperty
property
- the model property the serialize and deserialize when interacting with the database.type
- possible values includearray
orstruct
.registerCallbacks
- (defaults totrue
) Whether or not this plugin should automatically add the$deserializeJSONProperties
and$serializeProperties
callbacks. Set this to false if you want to invoke them or register them yourself.
Once you have initialized your model, there is no extra work required to start using the functionality of this plugin.
Simply add structure data to your JSON property. That's it!
The JSON proerties plugin works by adding callbacks to the initialized model to transparently serialize/deserialize complex data types into strings that can be stored in a database.
$deserializeJSONProperties
is called onaferFind
andafterSave
$serializeJSONProperties
is called onbeforeValidation
andbeforeDelete
This plugin was created by James Gibson and is now maintained by Chris Peters with support from Liquifusion Studios.
The MIT License (MIT)
Copyright (c) 2015 Liquifusion Studios