Giter Club home page Giter Club logo

php-handlersocket's Introduction

php-handlersocket

Description

This extension provide API for communicating with HandlerSocket plugin for MySQL.

This module is a copy of a repository from https://code.google.com/p/php-handlersocket/ which at current day is dead.

Resources

Current status

For now this repository was created to repair problem with segfaulting HandlerSocketIndex class while performing insert. I cannot say if I'll be able to maintain this package further.

Summary

This extension provide API for communicating with HandlerSocket plugin for MySQL.

libhsclient binding for PHP.

notice

It may be defective for a test version.

implemented

implemented configure options source file hsclient none (default) handlersocket.cc native --disable-handlersocket-hsclient handlersocet.c

Installation

required to compile the libhsclient.

phpize
./configure  or  ./configure --disable-handlersocket-hsclient
make
make install

A successful install will have created handlersocket.so and put it into the PHP extensions directory. You'll need to and adjust php.ini and add an extension=handlersocket.so line before you can use the extension.

Class synopsis

Class

Example

<?php
$host = 'localhost';
$port = 9998;
$port_wr = 9999;
$dbname = 'hstestdb';
$table = 'hstesttbl';

//GET
$hs = new HandlerSocket($host, $port);
if (!($hs->openIndex(1, $dbname, $table, HandlerSocket::PRIMARY, 'k,v')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

$retval = $hs->executeSingle(1, '=', array('k1'), 1, 0);

var_dump($retval);

$retval = $hs->executeMulti(
    array(array(1, '=', array('k1'), 1, 0),
          array(1, '=', array('k2'), 1, 0)));

var_dump($retval);

unset($hs);


//UPDATE
$hs = new HandlerSocket($host, $port_wr);
if (!($hs->openIndex(2, $dbname, $table, '', 'v')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

if ($hs->executeUpdate(2, '=', array('k1'), array('V1'), 1, 0) === false)
{
    echo $hs->getError(), PHP_EOL;
    die();
}

unset($hs);


//INSERT
$hs = new HandlerSocket($host, $port_wr);
if (!($hs->openIndex(3, $dbname, $table, '', 'k,v')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

if ($hs->executeInsert(3, array('k2', 'v2')) === false)
{
    echo $hs->getError(), PHP_EOL;
}
if ($hs->executeInsert(3, array('k3', 'v3')) === false)
{
    echo 'A', $hs->getError(), PHP_EOL;
}
if ($hs->executeInsert(3, array('k4', 'v4')) === false)
{
    echo 'B', $hs->getError(), PHP_EOL;
}

unset($hs);


//DELETE
$hs = new HandlerSocket($host, $port_wr);
if (!($hs->openIndex(4, $dbname, $table, '', '')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

if ($hs->executeDelete(4, '=', array('k2')) === false)
{
    echo $hs->getError(), PHP_EOL;
    die();
}

php-handlersocket's People

Contributors

pdeszynski avatar

Watchers

 avatar  avatar

Forkers

tongjieyi

php-handlersocket's Issues

extension future

Hello

Will this extension be developed in future? Or this is just a copy of dead extension from google code?

I found 3 HS ext for PHP:

  1. HandlerSocketi - https://github.com/kjdev/php-ext-handlersocketi
    Without documentation. I tried to parse classes with reflection but all is bad :)
  2. PHP-Handlersocket - https://github.com/perusio/php-handlersocket
    Last commmit was 2 years ago. So I even didnt try to use it.
  3. PHP Handlersocket (this repo) - https://github.com/piteer1/php-handlersocket
    I installed this extension. Seems all is ok. But I was wonderful that php extension works much slower that PHP classes for HanderSocket (Ex: https://github.com/tz-lom/HSPHP). So have can it be that native php code executes more and more quicker
    than php extension?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.