2017 © Pedro Peláez
 

asgard-bundle data

image

asgard/data

  • Friday, May 13, 2016
  • by leyou
  • Repository
  • 1 Watchers
  • 0 Stars
  • 282 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Data

Build Status, (*1)

Data is package for key-value database storage., (*2)

, (*3)

Installation

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.*

, (*5)

Usage in the Asgard Framework

$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)

, (*7)

Usage outside the Asgard Framework

$config = [
    'host' => 'localhost',
    'user' => 'root',
    'password' => '',
    'database' => 'asgard',
    'prefix' => '',
    'driver' => 'mysql'
];
$db = new \Asgard\Db\DB($config);
$data = new \Asgard\Data\Data($db);

, (*8)

Fetch a value

$data->get('key', 'default'); #'default' if returned in the value could not fetched
#or
$data['key'];

, (*9)

Store a value

$data->set('key', 'value');
#or
$data['key'] = 'value';

, (*10)

Delete a key

$data->delete('key');
#or
unset($data['key']);

, (*11)

Check for a key existence

$data->has('key');
#or
isset($data['key']);

, (*12)

Working with different data types

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');

Contributing

Please submit all issues and pull requests to the asgardphp/asgard repository., (*15)

License

The Asgard framework is open-sourced software licensed under the MIT license, (*16)

The Versions

13/05 2016

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Michel Hognerud

13/05 2016

v0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud

12/05 2016

v0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud

13/06 2015

v0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud

09/09 2014

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud