-
Notifications
You must be signed in to change notification settings - Fork 14
Home
Ryan Liu edited this page Jan 9, 2015
·
5 revisions
Welcome to the php-ext-handlersocketi wiki!
See Getting Started with the MariaDB HandlerSocket Plugin
$hs = new HandlerSocketi('127.0.0.1', 9998);
$fields = ['id', 'username', 'age'];
$query = $hs->open_index('dbname', 'users', $fields);
- Get by primary key
$result = $query->find(5);
var_dump($result);
- Find by primary key
$result = $query->find(['<=' => 10], ['limit' => 5, 'offset' => 2]);
var_dump($result);
- Get by index
$options = ['index' => 'username'];
$query = $hs->open_index('dbname', 'users', $fields, $options);
$result = $query->find('ryan');
var_dump($result);
- Insert
$query = $hs->open_index('dbname', 'users', $fields);
$result = $query->insert([
'id' => 2,
'username' => 'jane',
'age' => 20,
]);
var_dump($result);
- Delete/Remove
$options = ['index' => 'username'];
$query = $hs->open_index('dbname', 'users', $fields, $options);
$result = $query->remove('ryan');
var_dump($result);
- Update
$options = ['index' => 'username'];
$query = $hs->open_index('dbname', 'users', $fields, $options);
$result = $query->update('jane', [2, 'jane', 18]);
var_dump($result);
$options = ['index' => 'username'];
$query = $hs->open_index('dbname', 'users', $fields, $options);
$result = $query->multi([
['find', 'ryan'],
['find', 'jane'],
]);
var_dump($result);