1 Star 0 Fork 1

阿债 / php-handlersocket

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
阿债 提交于 2015-02-12 14:57 . 更新文档

php-handlersocket

PHP调用MySQL插件HandlerSocket,基于 kjdev/php-ext-handlersocketi

Connect DB, use table and fields

$hs = new HandlerSocket('db_test', '127.0.0.1', 9999);
$fields = ['id','username','score','modified_at','is_active'];
$hs->open('t_users', $fields);

Write records

Insert:

$now = date('Y-m-d H:i:s');
$row = [1,'ryan',60,$now,true];
$hs->insert(array_combine($fields, $row));

Update:

#new data, pkey or index, id or index value
$hs->update([1, 'David', 80, $now, true], null, 1); 

Delete:

$hs->delete(1); #the id

Read

Get one row by id:

$ryan = $hs->get(1);

Get one row by index:

$ryan = $hs->get('username', 'ryan');

Find some rows by pkey or index:

#pkey or index, operation, value, limit, offset
#operation: > >= < <=
$ryan = $hs->all(null, '>=', 1, 3, 1);

Find some rows, pkey or index in value list:

$ryan = $hs->in('username', 'ryan', 'jane');
#or
$ryan = $hs->in('username', ['ryan', 'jane']);
PHP
1
https://gitee.com/azhai/php-handlersocket.git
git@gitee.com:azhai/php-handlersocket.git
azhai
php-handlersocket
php-handlersocket
master

搜索帮助