LoginSignup
0

More than 5 years have passed since last update.

PHPからGroongaを利用する - GCommandクラス

Last updated at Posted at 2014-12-01

GCommandクラス

PHP bindings for Groonga.

GCommand {
  /* メソッド */
  public void __construct(Groonga object, string command)
  public void __destruct(void)
  public void __set(string key, string value)
  public string __get(string key)
  public mixed exec([bool assoc])
}

コンストラクタ GCommand::__construct

基礎クラスの生成

$command = new GCommand(groonga, 'status');

引数

名前 概要
object Groonga Groongaオブジェクト
command string コマンド名

戻り値

なし

  $gdb = new Groonga('./db/test.db');

  $command = $gdb->command('status');
  print_r($command);

結果

GCommand Object
(
)

セッター GCommand::__set

変数へデータを設置する

$gdb->__set('table', 'Users');

引数

名前 概要
key string 変数名
value string

戻り値

なし

  $gdb = new Groonga('./db/test.db');

  $command = $gdb->command('load');
  $command->talbe = 'Users';
  $command->values = '[ { "key":"bob" } ]';
  $result = $command->exec();
  print_r($result);

結果

true

ゲッター GCommand::__get

変数を取得する

$gdb->__get('table');

引数

名前 概要
key string 変数名

戻り値

string 変数の値

  $gdb = new Groonga('./db/test.db');

  $command = $gdb->command('load');
  $command->talbe = 'Users';
  echo $command->talbe;

結果

Users

実行 GCommand::exec

コマンドを実行する

$result = $gdb->exec(1);

引数

名前 概要
assoc boolean 取得タイプ

戻り値

コマンド結果の取得

  $gdb = new Groonga('./db/test.db');

  $command = $gdb->command('status');
  $result = $command->exec(1);
  print_r($result);

結果

Array
(
    [alloc_count] => 142
    [starttime] => 1417398397
    [uptime] => 0
    [version] => 4.0.7
    [n_queries] => 0
    [cache_hit_rate] => 0
    [command_version] => 1
    [default_command_version] => 1
    [max_command_version] => 2
)

PHPからGroongaを利用する-Groongaクラス
PHPからGroongaを利用する-GCommandクラス
PHPからGroongaを利用する-GTableクラス
PHPからGroongaを利用する-GColumnクラス
PHPからGroongaを利用する-GLoadクラス
PHPからGroongaを利用する-GDeleteクラス
PHPからGroongaを利用する-GSelectクラス

PHPからGroongaを利用する-PHPバインディング

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0