Watch 1 Star 0 Fork 1

阿债 / php-handlersocketPHPMIT

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
PHP调用MySQL插件HandlerSocket,基于kjdev/php-ext-handlersocketi spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

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

Comments ( 0 )

You need to Sign in for post a comment

Help Search