2017 © Pedro Peláez
 

library php-cassandra-binary

PHP library for Cassandra database via a binary protocol

image

evseevnn/php-cassandra-binary

PHP library for Cassandra database via a binary protocol

  • Thursday, February 9, 2017
  • by evseevnn
  • Repository
  • 19 Watchers
  • 72 Stars
  • 46,558 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 38 Forks
  • 36 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

PHP library for Cassandra

Sorry, this repository deprecated and not maintained anymore. Please use https://github.com/duoshuo/php-cassandra

Build Status , (*1)

Cassandra client library for PHP, using the native binary protocol., (*2)

Roadmap for version 0.2.0

  • UUID generation
  • timestamp only with microsecond
  • using v2 protocol
  • speedup
  • the ability to specify the settings (setup default consistency level and more)
  • more fixes

Known issues

  • decimal and timestamps have bugs especially in collections (map,set,list)
  • connection handling e.g. timeouts

Installation

PHP 5.4+ is required. There is no need for additional libraries., (*3)

Append dependency into composer.json, (*4)

    ...
    "require": {
        ...
        "evseevnn/php-cassandra-binary": "dev-master"
    }
    ...

Base Using

<?php

$nodes = [
    '127.0.0.1',
    '192.168.0.2:8882' => [
        'username' => 'admin',
        'password' => 'pass'
    ]
];

// Connect to database.
$database = new evseevnn\Cassandra\Database($nodes, 'my_keyspace');
$database->connect();

// Run query.
$users = $database->query('SELECT * FROM "users" WHERE "id" = :id', ['id' => 'c5420d81-499e-4c9c-ac0c-fa6ba3ebc2bc']);

var_dump($users);
/*
    result:
        array(
            [0] => array(
                'id' => 'c5420d81-499e-4c9c-ac0c-fa6ba3ebc2bc',
                'name' => 'userName',
                'email' => 'user@email.com'
            )
        )
*/

// Keyspace can be changed at runtime
$database->setKeyspace('my_other_keyspace');
// Get from other keyspace
$urlsFromFacebook = $database->query('SELECT * FROM "urls" WHERE "host" = :host', ['host' => 'facebook.com']);

Using transaction

    $database->beginBatch();
    // all INSERT, UPDATE, DELETE query append into batch query stack for execution after applyBatch
    $uuid = $database->query('SELECT uuid() as "uuid" FROM system.schema_keyspaces LIMIT 1;')[0]['uuid'];
    $database->query(
            'INSERT INTO "users" ("id", "name", "email") VALUES (:id, :name, :email);',
            [
                'id' => $uuid,
                'name' => 'Mark',
                'email' => 'mark@facebook.com'
            ]
        );

    $database->query(
            'DELETE FROM "users" WHERE "email" = :email;',
            [
                'email' => 'durov@vk.com'
            ]
        );
    $result = $database->applyBatch();

Supported datatypes

All types are supported., (*5)

  • ascii, varchar, text Result will be a string.
  • bigint, counter, varint Converted to strings using bcmath.
  • blob Result will be a string.
  • boolean Result will be a boolean as well.
  • decimal Converted to strings using bcmath.
  • double, float, int Result is using native PHP datatypes.
  • timestamp Converted to integer. Milliseconds precision is lost.
  • uuid, timeuuid, inet No native PHP datatype available. Converted to strings.
  • list, set Converted to array (numeric keys).
  • map Converted to keyed array.

The Versions

09/02 2017

dev-master

9999999-dev

PHP library for Cassandra database via a binary protocol

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Evseev Nikolay

04/11 2014

dev-revert-41-master

dev-revert-41-master

PHP library for Cassandra database via a binary protocol

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Evseev Nikolay

22/09 2014

dev-revert-24-counter-batch

dev-revert-24-counter-batch

PHP library for Cassandra database via a binary protocol

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Evseev Nikolay

31/07 2014

dev-develop

dev-develop

PHP library for Cassandra database via a binary protocol

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Evseev Nikolay

31/07 2014

dev-hotfix-connection-without-auth

dev-hotfix-connection-without-auth

PHP library for Cassandra database via a binary protocol

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Evseev Nikolay

24/07 2014

v0.1.0

0.1.0.0

PHP library for Cassandra database via a binary protocol

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Evseev Nikolay