the-php-swarm/bluphant

A PHP library to interact with Bluzelle Blockchain Database

dev-master 2018-05-21 23:41 UTC

README

Build Status

Bluphant is a PHP library to interact with Bluzelle Blockchain Database.

Bluzelle is a Blockchain Database that works in a system of swarms, this makes the availability, integrity, integrability and the consistency be natural. This is a PHP Database Adapter for Bluzelle.

Usage

Before everything, Bluphant is an Adapter, and to use it you just have to place it as an $adapter for you Database Layer.

It might be interesting to build other 2 classes to work with this:

  • Data Mapper

    $userMapper = new UserMapper($adapter);
  • Models

    $user = new User("Everchanging Joe", "joe@example.com");
    $userMapper->insert($user);

How to

Installation

Using Composer

{
  "repositories": [
    {
      "url": "https://github.com/the-php-swarm/bluphant.git",
      "type": "vcs"
    }
  ],
  "require": {
    "the-php-swarm/bliphant": "beta"
  }
}

Prepare Adapter

use Bluphant\BluphantAdapter;

$adapter = new BluphantAdapter('127.0.0.1', 8100);

$table = '3f966cd1-ef79-4464-b3be-81e84002550b';

Statements

Create

$adapter->insert($table, [
    "key" => "key1",
    "value" => "sample value"
]);

Read

$adapter->select($table, [
    "key" => "key1"
]);

Update

$adapter->update($table, [
    "key" => "key1",
    "value" => "sample value 2"
]);

Delete

$adapter->delete($table, [
    "key" => "key1"
]);

Keys

$adapter->keys($table);

Execute

echo $adapter->execute();

Reference