downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

TokyoTyrantTable::putCat> <TokyoTyrantTable::out
[edit] Last updated: Fri, 25 May 2012

view this page in

TokyoTyrantTable::put

(PECL tokyo_tyrant >= 0.1.0)

TokyoTyrantTable::put行を格納する

説明

public int TokyoTyrantTable::put ( string $key , array $columns )

新しい行をデータベースに格納します。このメソッドのパラメータ key は行の主キーで、NULL を渡すと一意な id を新たに生成します。value は配列で、行の内容を表します。通常は、キーと値のペアとなります。

パラメータ

key

行の主キー。

columns

行の内容。

返り値

成功した場合に主キーを返します。エラー時には TokyoTyrantException をスローします。

例1 TokyoTyrantTable::put() の例

<?php
/* テーブルデータベースに接続します */
$tt = new TokyoTyrantTable("localhost"1979);

/* null を渡して新しい uid を生成します */
$index $tt->put(null, array("column1" => "some data""column2" => "more data"));

/* 行を取得します */
var_dump($tt->get($index));

/* 既存の行を変更します */
$tt->put($index, array("column1" => "other data""column2" => "better data"));

/* 行を取得します */
var_dump($tt->get($index));
?>

上の例の出力は以下となります。

array(2) {
  ["column1"]=>
  string(9) "some data"
  ["column2"]=>
  string(9) "more data"
}
array(2) {
  ["column1"]=>
  string(10) "other data"
  ["column2"]=>
  string(11) "better data"
}

参考



add a note add a note User Contributed Notes TokyoTyrantTable::put
There are no user contributed notes for this page.

 
show source | credits | sitemap | contact | advertising | mirror sites