-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
45 lines (36 loc) · 852 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require_once __DIR__ ."/vendor/autoload.php";
$transformer = new \CNM\Transformer\Transformer();
$metadata = array(
'table' => 'tests',
'fields' => array(
'id' => array(
'type' => 'integer',
'default' => 0
),
'name' => array(
'type' => 'string',
'default' => ''
),
'options' => array(
'type' => 'json',
'default' => array()
)
)
);
$adapter = new \CNM\Metadata\Adapter\ArrayAdapter($metadata);
$data = array(
'name' => 'Test Data Transformer',
'options' => array(
'opt1' => true,
'opt2' => false
)
);
$encodedData = $transformer->encode($data, $adapter);
/**
* logic for inserting data to db
*/
/**
* Get data from db
*/
$decodeData = $transformer->decode($data, $adapter);