popojargo/php-on-couch

此包已废弃,不再维护。作者建议使用php-on-couch/php-on-couch包。

CouchDB NoSQL数据库在PHP中的访问

2.0.3 2017-05-24 16:40 UTC

README

Latest Stable VersionLatest Unstable VersionBuild StatusDocumentation StatusScrutinizer Code QualitycodecovLicense

🔥完整文档请访问 http://php-on-couch.readthedocs.io 🔥

目录

简介

PHP On Couch旨在提供一个简单的方法,通过CouchDB 文档PHP进行交互。

近期更改

完整更改列表请访问这里

安装和测试

使用composer安装库: composer require php-on-couch/php-on-couch。更多关于安装的详细信息请访问这里

要测试应用程序,请参阅本主题

组件和文档

完整API文档请访问此链接

示例

完整示例请参考数据库示例文档示例

首先,您需要通过它们的命名空间导入主要组件。如果您使用composer,我建议您使用它们的自动加载,这很容易设置。否则,您可以使用您自己的自动加载函数或使用一些命名空间转义的基本require。

use  PHPOnCouch\CouchClient; //The CouchDB client object

以下是一个基本操作的示例

// Set a new connector to the CouchDB server
$client = new CouchClient('http://my.couch.server.com:5984', 'my_database');

// document fetching by ID
$doc = $client->getDoc('some_doc_id');
// updating document
$doc->newproperty = array("hello !", "world");
try {
    $client->storeDoc($doc);
} catch (Exception $e) {
    echo "Document storage failed : " . $e->getMessage() . "<BR>\n";
}

以下是如何获取视图的快速示例

// view fetching, using the view option limit
try {
    $view = $client->limit(100)->getView('orders', 'by-date');
} catch (Exception $e) {
    echo "something weird happened: " . $e->getMessage() . "<BR>\n";
}

最后,如何使用CouchDocument类。

//using couch_document class :
$doc = new CouchDocument($client);
$doc->set(array('_id' => 'JohnSmith', 'name' => 'Smith', 'firstname' => 'John')); //create a document and store it in the database
echo $doc->name; // should echo "Smith"
$doc->name = "Brown"; // set document property "name" to "Brown" and store the updated document in the database

社区

贡献

请随时做出任何贡献。所有贡献都必须遵循代码风格,并且还必须附带有效且完整的测试。

完成更多测试的帮助将非常受欢迎。

反馈

Gitter chat

请随时提交反馈、错误报告和功能请求!我们的联系方式是 phponcouch@gmail.com