Skip to content

Instantly share code, notes, and snippets.

@do-aki
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save do-aki/419953a481d0289ffbbb to your computer and use it in GitHub Desktop.
Save do-aki/419953a481d0289ffbbb to your computer and use it in GitHub Desktop.
use groonga with nise-nabe/groonga-http-php
<?php
require __DIR__ . '/vendor/autoload.php';
use Groonga\Http\Client;
$grn = new Client('http://localhost:10041');
$grn->tableCreate('Site', ['flags' => 'TABLE_HASH_KEY','key_type' => 'ShortText']);
$grn->columnCreate('Site', 'title', 'COLUMN_SCALAR', 'ShortText');
$grn->load('Site', json_encode([
["_key" => "http://example.org/","title" => "This is test record 1!"],
["_key" => "http://example.net/","title" => "test record 2."],
]));
$r = $grn->select('Site', ['query' => '_id:1']);
var_dump($r);
array(2) {
[0] => array(3) {
[0] => int(0)
[1] => double(1409552209.2692)
[2] => double(0.0011940002441406)
}
[1] => array(1) {
[0] => array(3) {
[0] => array(1) {
[0] => int(1)
}
[1] => array(3) {
[0] => array(2) {
[0] => string(3) "_id"
[1] => string(6) "UInt32"
}
[1] => array(2) {
[0] => string(4) "_key"
[1] => string(9) "ShortText"
}
[2] => array(2) {
[0] => string(5) "title"
[1] => string(9) "ShortText"
}
}
[2] => array(3) {
[0] => int(1)
[1] => string(19) "http://example.org/"
[2] => string(22) "This is test record 1!"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment