kgrhck / php-on-couch
CouchDB NoSQL数据库在PHP中的访问
4.0.0
2022-01-31 01:45 UTC
Requires
- php: >=5.6.0
Requires (Dev)
- dev-master
- 4.0.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.6a
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 1.6.1.x-dev
- 1.6.1
- 1.0.1-p2
- 1.0.1-p1
- dev-feature/enhance-auth
- dev-feature/remove-php-dot-env
- dev-feature/update-changelist-for-2.0.7
- dev-fix/socket-adapter
- dev-fix/continuousQuery
- dev-feature/support-conflicts-for-find
- dev-fix/find-as-array
- dev-feature/scheduler
- dev-forked_master
This package is auto-updated.
Last update: 2024-09-10 17:56:07 UTC
README
🔥完整的文档,请访问http://php-on-couch.readthedocs.io 🔥
目录
简介
PHP On Couch 提供了一种简单的方法,使用 CouchDB 文档 与 PHP 进行交互。
支持PHP 5.6及以上版本 🚀
最近更改
完整的更改列表,请访问此处
安装和测试
使用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