popojargo / php-on-couch
2.0.3
2017-05-24 16:40 UTC
Requires
- php: >=5.2.0
Requires (Dev)
- dev-master
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.6.1.x-dev
- 1.6.1
- 1.0.1-p2
- 1.0.1-p1
- dev-feature/deploymentScripts
- dev-feature/fixHttpsProblem
- dev-feature/migrateDocToSphinx
- dev-feature/replace_coveralls
- dev-feature/add_test_for_203
- dev-kl3sk_path2_update
- dev-feature/http_adapter
- dev-feature/mango_query
- dev-updatedorigin
- dev-develop
This package is auto-updated.
Last update: 2022-02-01 13:02:41 UTC
README
🔥完整文档请访问 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
社区
贡献
请随时做出任何贡献。所有贡献都必须遵循代码风格,并且还必须附带有效且完整的测试。
完成更多测试的帮助将非常受欢迎。
反馈
请随时提交反馈、错误报告和功能请求!我们的联系方式是 phponcouch@gmail.com