kosatyi/datamodel

PHP data access and serving class

v0.0.5 2020-12-26 21:29 UTC

This package is auto-updated.

Last update: 2021-04-12 19:39:45 UTC


README

PHP data access and serving class

68747470733a2f2f706f7365722e707567782e6f72672f6b6f73617479692f646174616d6f64656c2f76657273696f6e 68747470733a2f2f706f7365722e707567782e6f72672f6b6f73617479692f646174616d6f64656c2f646f776e6c6f616473 68747470733a2f2f706f7365722e707567782e6f72672f6b6f73617479692f646174616d6f64656c2f6c6963656e7365

If you just want to access the array of model data from the context of a container object, you should use either the attr method

    use Kosatyi\DataModel as Model;
    $model = new Model();
    $model->data([
        'prop' => 'value',
        'list' => [
            'item0','item1','item2'
        ],
        'map'  = [
            'prop1'=> 'value1',
            'prop2'=> 'value2' 
        ]
    ]);
    echo $model->attr('prop');
    echo $model->attr('list.0');
    echo $model->attr('map.prop1');
    $model->attr('list.1','item1-changed');
    $model->attr('prop','value-changed');
    $model->attr('map.prop2','value2');