dev-master
9999999-dev
MIT
The Requires
- php >=5.5.9
- asgard/db ~0.3.0
- doctrine/dbal ^2.0
by Michel Hognerud
Data is package for key-value database storage., (*2)
If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries., (*4)
composer require asgard/data 0.*
$data = $container['data'];
The container is often accessible as a method parameter or through a ContainerAware object. You can also use the singleton but it is not recommended., (*6)
$config = [ 'host' => 'localhost', 'user' => 'root', 'password' => '', 'database' => 'asgard', 'prefix' => '', 'driver' => 'mysql' ]; $db = new \Asgard\Db\DB($config); $data = new \Asgard\Data\Data($db);
$data->get('key', 'default'); #'default' if returned in the value could not fetched #or $data['key'];
$data->set('key', 'value'); #or $data['key'] = 'value';
$data->delete('key'); #or unset($data['key']);
$data->has('key'); #or isset($data['key']);
Register a type, (*13)
$data->register('obj', function($obj) { return serialize($obj); }, function($str) { return unserialize($str); } );
Store a value with a specific type, (*14)
$obj = new StdClass; $obj->name = 'bob'; $data->set('key', $obj, 'obj');
Please submit all issues and pull requests to the asgardphp/asgard repository., (*15)
The Asgard framework is open-sourced software licensed under the MIT license, (*16)
MIT