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/d91584e38efd9f844d30 to your computer and use it in GitHub Desktop.
Save do-aki/d91584e38efd9f844d30 to your computer and use it in GitHub Desktop.
<?php
$grn = grn_ctx_init();
grn_ctx_connect($grn, "localhost", 10043);
grn_ctx_send($grn, "table_create Site TABLE_HASH_KEY ShortText");
grn_ctx_recv($grn);
grn_ctx_send($grn, "column_create Site title COLUMN_SCALAR ShortText");
grn_ctx_recv($grn);
grn_ctx_send($grn, 'load --table Names --values [{\"_key\":\"aaa\",\"name\":\"name1\"},{\"_key\":\"bbb\",\"name\":\"name2\"}]');
grn_ctx_recv($grn);
grn_ctx_send($grn, "select Site --query id:1");
$r = grn_ctx_recv($grn);
var_dump($r);
array(1) {
[0] => array(2) {
[0] => int(0)
[1] => string(120) "[[[1],[["_id","UInt32"],["_key","ShortText"],["title","ShortText"]],[1,"http://example.org/","This is test record 1!"]]]"
}
}
===========================================================
[
[
[1],
[
["_id","UInt32"],
["_key","ShortText"],
["title","ShortText"]
],
[1,"http://example.org/","This is test record 1!"]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment