Skip to content

Type Normalization

Romans Malinovskis edited this page Aug 19, 2016 · 10 revisions

Agile Data recognizes some of the basic types. All persistence drivers are requested to properly handle those types. For instance a type 'date' will be set using a PHP's default date type. When storing into MySQL this must be converted to the native format (stirng). On other hand, if that is saved into 'MongoDB' then MongoDate must be used instead.

Types that are normalized by Agile Data

type alias(es) description native sql mongo
int integer will cast to int make sure it's not passed as a string. -394, "49" 49 49
float decimal number with floating point 3.2884,
money Will convert loosly-specified currency into float or dedicated format for storage. Optionally support 'fmt' proprety. "£38,294.4800002" 38294.48
bool boolean true / false type value. Optionally specify 'enum'=>['Y','N'] to store true as 'Y' and false as 'N'. By default uses [1,0]. true 1 true
array Optionally pass 'fmt' option, which is 'json' by default. Will json_encode and json_decode(..., true) the value if database does not support array storage. [2=>"bar"] {2:"bar"} stored as-is
binary Supports storage of binary data

Clone this wiki locally