tz-lom/hsphp
最新稳定版本:v1.21
Composer 安装命令:
composer require tz-lom/hsphp
包简介
Client library for MySQL HandlerSocket extension.
关键字:
README 文档
README
HandlerSocker Library for PHP
This library provides an API for communicating with the HandlerSocket plugin for MySQL compatible databases(MySQL, MariaDB, Percona).
For more information on HandlerSocket, check out the MariaDB Documentation on HandlerSocket here.
Installation
Once you have composer installed, run the following in your php project directory:
php composer.phar require tz-lom/hsphp --no-update
Usage Examples
Select
$c = new \HSPHP\ReadSocket(); $c->connect(); $id = $c->getIndexId('data_base_name', 'table_name', '', 'id,name,some,thing,more'); $c->select($id, '=', array(42)); // SELECT WITH PRIMARY KEY $response = $c->readResponse(); //SELECT with IN statement $c = new \HSPHP\ReadSocket(); $c->connect(); $id = $c->getIndexId('data_base_name', 'table_name', '', 'id,name,some,thing,more'); $c->select($id, '=', array(0), 0, 0, array(1,42,3)); $response = $c->readResponse();
Update
$c = new \HSPHP\WriteSocket(); $c->connect('localhost',9999); $id = $c->getIndexId('data_base_name','table_name','','k,v'); $c->update($id,'=',array(100500),array(100500,42)); // Update row(k,v) with id 100500 to k = 100500, v = 42 $response = $c->readResponse(); // Has 1 if OK
Batch update
$c = new \HSPHP\WriteSocket(); $c->connect('localhost',9999); $id = $c->getIndexId('data_base_name','table_name','','k,v'); $c->update($id,'=',array(100500),array(100500,42), 2, 0, array(100501, 100502)); // Update rows where k IN (100501, 100502) $response = $c->readResponse(); // Has 1 if OK
Delete
$c = new \HSPHP\WriteSocket(); $c->connect('localhost',9999); $id = $c->getIndexId('data_base_name','table_name','','k,v'); $c->delete($id,'=',array(100500)); $response = $c->readResponse(); //return 1 if OK
Insert
$c = new \HSPHP\WriteSocket(); $c->connect('localhost',9999); $id = $c->getIndexId('data_base_name','table_name','','k,v'); $c->insert($id,array(100500,'test\nvalue')); $response = $c->readResponse(); //return array() if OK
Increment
$c = new \HSPHP\WriteSocket(); $c->connect('localhost',9999); $id = $c->getIndexId('data_base_name','table_name','','v'); $c->increment($id,'=',array(100500),array(2)); // Increment v column by 2 $response = $c->readResponse(); // Has 1 if OK
Decrement
$c = new \HSPHP\WriteSocket(); $c->connect('localhost',9999); $id = $c->getIndexId('data_base_name','table_name','','v'); $c->decrement($id,'=',array(100500),array(2)); // Decrement v column by 2 $response = $c->readResponse(); // Has 1 if OK
统计信息
- 总下载量: 32.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 101
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2013-01-11