Quantcast
Channel: 一言多いプログラマーの独り言
Viewing all articles
Browse latest Browse all 846

PHP-on-Couchを利用して、Apache CouchDBにアクセス、ドキュメント更新

$
0
0
PHP-on-Couchを利用して、Apache CouchDBにアクセス、ドキュメント更新です。ORMライクで、非常に楽。


use PHPOnCouch\CouchClient;

// 接続
$client = new CouchClient('http://admin:password@127.0.0.1:5984', 'customers');

// IDでドキュメントデータを取得
$doc = $client->getDoc('5945d346-f70e-46bb-886f-2dc88465dfe5');

$doc->firstname = "鈴木";
$doc->lastname = "一郎";
$doc->username = "suzukiichiro";
$doc->lastname = "suzukiichiro@example.com";

try {
$client->storeDoc($doc);
} catch (Exception $e) {
echo "Document storage failed : " . $e->getMessage() ;
}

参考サイト
PHPのApache CouchDBデータアクセスライブラリ「PHP-on-Couch」

Viewing all articles
Browse latest Browse all 846

Trending Articles