码云 Gitee IDE 全新上线——支持 Git 管理的轻量在线编码环境
Watch Star Fork

阿债 / php-handlersocketPHPMIT

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
PHP调用MySQL插件HandlerSocket,基于kjdev/php-ext-handlersocketi
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md 1.08 KB

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']);

项目点评 ( 0 )

你可以在登录后,发表评论

搜索帮助