`
viproc
  • 浏览: 46332 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Zend框架:Zend_Nosql_Mong​​o组件建议

阅读更多

Zend框架:Zend_Nosql_Mong​​o组件建议

Proposed Component Name建议的组件名称Developer Notes开发人员说明Proposers提议者Zend Liaison Zend的联络Revision修订
Zend_Nosql_Mongo Zend_Nosql_Mong​​o
http://framework.zend.com/wiki/display/ZFDEV/Zend_Nosql_Mongo http://framework.zend.com/wiki/display/ZFDEV/Zend_Nosql_Mongo
Valentin Golev 瓦伦丁Golev
TBD待定
1.0 - 6 January 2010: Initial Draft. 1.0 - 2010年1月6日:初步草案。 (wiki revision: 9) (维基修订:9)

Table of Contents目录表

<style type="text/css"> <!-- div.rbtoc1262799713448 {margin-left:0px; padding:0px} div.rbtoc1262799713448 ul {list-style:none; margin-left:0px; padding-left:0px} div.rbtoc1262799713448 li {margin-left:0px; padding-left:0px} --> </style>

1. 1。 Overview概述

Zend_Nosql_Mongo is a namespace containing wrappers and adapters for PHP Mongo classes, intended to make them more handy, simple and compatible with other ZF classes, such as Zend_Paginator. Zend_Nosql_Mong​​o是一个命名空间包含PHP蒙戈类的包装和适配器,旨在使他们更方便,简单,并与其他的ZF类,如Zend_Paginator,兼容。

2. 2。 References参考文献

 

 

 

 

3. 3。 Component Requirements, Constraints, and Acceptance Criteria组件需求,约束和验收标准

 

  • This component will expose the entire MongoDB API此组件揭露整个MongoDB的API
  • This component will expose even the API not supported by PHP driver if it is exposed by Mongo DB commands此组件公开甚至PHP驱动程序不支持的API,如果它是由暴露蒙戈 DB命令
  • This component will provide class for a Mongo Object.此组件提供一个蒙戈对象类。
    • In a mongo object will be only string, int, bool, double, null, array (of any of these types, recursively), Mongo Object, date, MongoID, binary, regexp and JS Code fields.在蒙戈对象是唯一的字符串,整型,布尔,双,空,数组(这些类型的任何递归),蒙戈对象,日期,MongoID,二进制,REGEXP和JS代码领域。 See also Data Types in Mongo 数据类型也蒙戈
    • Fields will be able to be accessed as a member variables, like $object->subObject->subObjField for { subObject : { subObjField : 17 } }.字段能够作为一个成员变量的访问,如$对象>子对象subObjField {子对象:{subObjField 17}} 。
  • This component will provide objects for individual documents as well as document collections此组件提供单独的文件以及文档集合中的对象
    • Document objects will allow arbitrary fields Document对象允许任意字段
    • Document objects will provide accessors for document IDs Document对象提供的文档ID的访问器
    • Document objects will allow arbitrary fields Document对象允许任意字段
    • Document objects will be instances of a class which extends BSON Object Document对象扩展BSON对象的类的实例
    • Document objects will allow atomic operations like increment Document对象允许原子操作 ,像增量
    • Document Collections will be iterable所收集的文件被迭代的
    • Document Collections will be countable文档集合是可数
    • Document Collections will allow adding and removing documents所收集的文件允许添加和删除文件
    • Document Collections will allow retrieving documents by ID所收集的文件允许通过ID检索文件
    • Document Collections will allow prohibition of arbitrary fields所收集的文件允许禁止任意字段
    • Document Collections will allow strong client-side typing of fields, like 'int' or 'int|array(int)|null'所收集的文件允许强大的客户端键入的字段,如“INT”或“INT |阵列(INT)| NULL'
    • Document Collections will allow validators for fields所收集的文件允许字段校验器
  • This component will allow using GridFS for storing files此组件允许使用存储文件GridFS
    • This component will be able to be used with Zend MVC此组件能够使用与Zend MVC
  • This component will provide a special object for Query此组件提供一个特殊的对象进行查询
    • Query will be countable查询被计数
    • Query will be iterable (by returning Cursor for iteration)查询可迭代(迭代返回游标)
  • This component will provide a special object for Cursor, which is returned by executing Query此组件提供执行的查询返回的光标,这是一个特殊的对象
    • Cursor will be countable光标是可数
    • Cursor will be iterable光标被迭代的
  • This component will allow to set a specific class for documents in specific collections, as soon as it implements a special interface此组件允许设置一个特定的集合中的文档的特定的类,只要它实现了一个特殊的接口
    • Cursor and Collection will return instances of these specific classes instead of usual Document classes光标和征收返回这些具体的类的实例,而不是通常的文件类

 

 

 

4. 4。 Dependencies on Other Framework Components其他的框架组件上的依赖关系

 

  • Zend_Exception Zend_Exception异常
  • Zend_Validate Zend_Validate
  • Zend_Paginator Zend_Paginator
  • Zend_Date Zend_Date的
  • Zend_Controller (for using GridFS with MVC) Zend_Controller的(使用MVC的GridFS)

 

 

 

5. 5。 Theory of Operation工作原理

Users create a link to Database, providing connection and db information to the Zend_Nosql_Mongo_Db.用户可以创建一个到数据库的链接,提供连接和DB信息的Zend_Nosql_Mong​​o_Db。
Then they can get a link to a specific collection (which will be created, if not exists).然后,他们可以得到一个链接到一个特定的集合(,如果不存在将创建)。

Users can create a Zend_Nosql_Mongo_Object from any array, as soon as all its values (recursively) can be converted to Mongo types.用户可以从任何数组创建一个Zend_Nosql_Mong​​o_Object,只要其所有值(递归)可以转换为蒙戈类型。 They can save Zend_Nosql_Mongo_Object to any collection.他们可以节省Zend_Nosql_Mong​​o_Object任何集合。 Saving operation, as well as retrieving, returns an instance of Zend_Nosql_Mongo_Document, which has a specific _id and knows a name of its collection.节能运行,以及检索,返回的Zend_Nosql_Mong​​o_Document实例,其中有一个具体_id的,并且知道其收集的名称。

Users can query any collection.用户可以查询任何集合。 They can add more and more conditions to the query.他们可以添加越来越多的条件查询。 When they are done, they can transform the query to a cursor and iterate or array-access it.当他们完成后,他们可以改变一个游标查询和迭代或数组访问。

Users can set a specific class for a document of specific collection.用户可以设置一个特定类的一个特定集合的文件。 It must implement Zend_Nosql_Mongo_Document_Interface or, even better, inherit from Zend_Nosql_Mongo_Document.它必须实现Zend_Nosql_Mong​​o_Document_Interface,或者甚至更好,从Zend_Nosql_Mong​​o_Document继承。 In this case, all cursors from queries on this collection will return the specified class.在这种情况下,所有游​​标在此集合的查询将返回指定的类。

Users can make document schema more strict by providing validators, strong typing and disallowing arbitrary fields for any collection.用户可以通过提供校验,强类型,不允许任何集合的任意领域更加严格的文档架构。 Values of each typed field will be tested if it has one of specified types.每个类型的字段的值将被测试,如果有指定的类型之一。 If not, it will be converted to the first of the type in the list.如果不是,它会被转换为类型列表中的第一。 If the conversion fails and 'null' is not allowed for the field, the exception is thrown instead of saving a document.如果转换失败,'null'是不是允许的领域,抛出异常,而不是保存文档。

 

6. 6。 Milestones / Tasks里程碑/任务

 

  • Milestone 1: Initial proposal and prototype里程碑1:最初的建议和原型
  • Milestone 2: All unit tests里程碑2:所有的单元测试
  • Milestone 3: Working code, all unit tests passed里程碑3:工作的代码,所有的单元测试通过
  • Milestone 4: Documentation里程碑4:文件

 

 

 

7. 7。 Class Index类指数

 

  • Zend_Nosql_Mongo_Db Zend_Nosql_Mong​​o_Db
  • Zend_Nosql_Mongo_Collection Zend_Nosql_Mong​​o_Collection
  • Zend_Nosql_Mongo_Document Zend_Nosql_Mong​​o_Document
  • Zend_Nosql_Mongo_Document_Interface Zend_Nosql_Mong​​o_Document_Interface
  • Zend_Nosql_Mongo_Object Zend_Nosql_Mong​​o_Object
  • Zend_Nosql_Mongo_Object_Interface Zend_Nosql_Mong​​o_Object_Interface
  • Zend_Nosql_Mongo_Query Zend_Nosql_Mong​​o_Query
  • Zend_Nosql_Mongo_Cursor Zend_Nosql_Mong​​o_Cursor
  • Zend_Nosql_Mongo_Id Zend_Nosql_Mong​​o_Id
  • Zend_Nosql_Mongo_Date Zend_Nosql_Mong​​o_Date
  • Zend_Nosql_Mongo_Regexp Zend_Nosql_Mong​​o_Regexp
  • Zend_Nosql_Mongo_Code Zend_Nosql_Mong​​o_Code
  • Zend_Nosql_Mongo_Gridfs Zend_Nosql_Mong​​o_Gridfs
  • Zend_Nosql_Mongo_Gridfs_File Zend_Nosql_Mong​​o_Gridfs_File
  • Zend_Nosql_Mongo_Gridfs_Cursor Zend_Nosql_Mong​​o_Gridfs_Cursor
  • Zend_Nosql_Mongo_Gridfs_Mvc? Zend_Nosql_Mong​​o_Gridfs_Mvc?

 

 

 

8. 8。 Use Cases用例

 

$db = Zend_Nosql_Mongo_Db(null, 'testdb');
$coll = $db->getCollection('testcollection');
for ($i = 0; $i < 100; $i++) {
echo $coll->save(new Zend_Nosql_Mongo_Object(array('field' => $i))->getId(), " is another unique id\n";
}
$q = $coll->ensureIndex('field')->query()->lowerThan('field', 10);
foreach ($q as $item) echo $item->field, " must be lower than 10!\n";

 

9. 9。 Class Skeletons类骨架

 

class Zend_Nosql_Mongo_Db {
public function __construct($host = null, $dbname = null) {}
public function setOptions($options) {}
public function getCollection($collectionName) {}
}
class Zend_Nosql_Mongo_Collection
implements IteratorAggregate, Countable {
public function __construct($db = null, $name = null) {}
public function setOptions($options) {}
public function setDocumentClass() {}
public function ensureIndex($field, $direction) {}
public function save(Zend_Nosql_Mongo_Object_Interface $object) {}
public function query() {}
public function count() {}
public function getIterator() {}
public function setFieldTypes($field, $types) {}
public function setFieldsTypes($fieldstypes) {}
public function setFieldValidator($field, $validator) {}
}
class Zend_Nosql_Mongo_Document
extends Zend_Nosql_Mongo_Object
implements Zend_Nosql_Mongo_Document_Interface {
public function __construct($data, Zend_Nosql_Mongo_Collection $collection) {}
public function getId() {}
public function getCollection() {}
public function save() {}
public function isChanged() {}
public function commit() {}
/*
* and functions for atomic operations
* see http://www.mongodb.org/display/DOCS/Updating#Updating-ModifierOperations
* see http://code.google.com/p/mongodloid/
*/
}
interface Zend_Nosql_Mongo_Document_Interface
extends Zend_Nosql_Mongo_Object_Interface {
public function __construct($data, Zend_Nosql_Mongo_Collection $collection) {}
public function getId() {}
public function getCollection() {}
public function save() {}
public function isChanged() {}
public function commit() {}
//and functions for atomic operations
}
class Zend_Nosql_Mongo_Object {
public function __construct($data) {}
function __get() {}
function __set() {}
}
interface Zend_Nosql_Mongo_Object_Interface {
public function __construct($data) {}
}
class Zend_Nosql_Mongo_Query
implements IteratorAggregate, Countable {
public function __construct(Zend_Nosql_Mongo_Collection $collection) {}
public function getCursor() {}
public function count() {}
public function getIterator() {}
/*
* and functions for all conditions
* see http://www.mongodb.org/display/DOCS/Advanced+Queries
* see http://code.google.com/p/mongodloid/
*/
}
class Zend_Nosql_Mongo_Cursor
implements Iterator, Countable {
public function __construct(Zend_Nosql_Mongo_Collection $collection, $query) {}
public function current() {}
public function key() {}
public function next() {}
public function rewind() {}
public function valid() {}
public function count() {}
}

 

  • Jan 21, 2010 2010年01月21日,

    Hi,嗨,

    some news of this very interesting proposal ?一些这个非常有趣的建议的消息?

  • Jan 21, 2010 2010年01月21日,

    Nosql..? NoSQL的..? I think that "Zend_Nosql" is not good namespace.我认为,“Zend_Nosql”没有良好的命名空间。

    Had not namespace(Zend_DocDb) been considered for document-oriented database?没有命名空间(Zend_DocDb)被认为是面向文档的数据库?
    @see CouchDb's proposal @看到CouchDB的建议

  • Feb 23, 2010 2010年02月23日,

    By the way my prototype mongodb adapter is coming along well.顺便说一下,我的原型mongodb的适配器是相处得很好。 It's taken a little longer than i expected它比我预想的长一点 . However it has become a completely different beast to what Valentin layed out above.然而,它已成为什么瓦伦丁上面奠定了一个完全不同的野兽。 Shortly i will have it available to discuss.不久,我会讨论。 Currently it does not support advanced queries, however i know Valentin is the author of mongodloid and figured i'd leave that to his area of expertise.目前它不支持高级的查询,但是我知道瓦伦丁mongodloid作者和我离开,他的专长领域。

  • Feb 23, 2010 2010年02月23日,

    Can both of you please stay in touch with me as I am keenly interested in opening up the source for my own proprietary efforts.都请你留在我身边,因为我深知在为我自己的专有努力开辟源有兴趣的联系。 Thanks!谢谢!

  • Mar 03, 2010 2010年03月03,

    Anything we can do to keep this going?任何我们可以做,以保持这个部落的? Is there a github repo or something we can download / contribute to?是否有一个GitHub的回购或东西,我们可以下载/贡献?

  • Mar 12, 2010 2010年03月12日,

    Sounds great, looking forward to testing it.听起来不错,期待测试。 Have you considered adding support for master/slave configurations?你有没有考虑加入支持主/从配置吗?

    http://www.snailinaturtleneck.com/blog/2010/02/01/mongo-mailbag-masterslave-configuration/ http://www.snailinaturtleneck.com/blog/2010/02/01/mongo-mailbag-masterslave-configuration/

  • Mar 24, 2010 2010年03月24日

    No need of docs for now I think ...我认为现在没有需要的文件...
    There is no need to polish things too much for now, just the base idea of the implementation should do just fine ;]有没有必要波兰现在的东西太多,只是实施的基本想法应该做的就好了;]

  • Mar 29, 2010 2010年03月29日

    Sorry for taking so long.对不起,这么长时间。 I didn't actually spend all that time writing docs我其实没有花所有的时间写作文档 ... ... ... I found a bug that required a significant modification of the source.我发现了一个错误,需要重大修改的源。

    Anyway here it is http://github.com/coen-hyde/Shanty-Mongo反正这里是http://github.com/coen-hyde/Shanty-Mongo

    The docs are a bit lack luster but it should give you the idea.该文档是有点缺乏光泽,但它应该给你的想法。

    Since this adapter is completely different to the proposal above i'll sign Zend's contributor form and create a separate proposal.由于此适配器是完全不同的上述建议,我会签署了Zend的贡献形式和创建一个单独的建议。

    One problem with my proposal is it requires php5.3.我的建议的一个问题是它需要PHP5.3。 But i figured the Zend Framework would eventually move to 5.3 or would allow 5.3 only components in the extras.但我想,Zend框架,最终迁移到5.3,或将允许在额外5.3的组件。 It would be possible to modify the adapter to not use late static binding but it should be a last resort as it would significantly reduce the developer friendliness.这将有可能修改适配器,不使用后期静态绑定,但它应该是最后的手段,因为它会显着降低开发人员友好。

    Any testing or feedback would is more than welcome.任何测试或反馈欢迎。 Unit tests would be worshiped.单元测试会被崇拜。

  • Mar 30, 2010 2010年03月30日,

    Hi Dennis,您好丹尼斯,

    Re Connections: Yeah i haven't put much thought into the connection aspect at all, completely open to suggestion from those who know better.重新连接:我没有连接方面投入过多考虑所有,完全开放,更懂得那些建议。

    Re Validators and Filters: I did originally have them separate but it was a bit ugly having the configuration options for properties spread across multiple arrays.重新校验器和过滤器:我没有让他们分开,但它是一个有点难看分散在多个阵列的属性配置选项。 Plus there are other requirements that are not validators or filters such as the 'AsReference' and planned 'AsPartial'.再加上有其他不属于验证器或过滤器,如“AsReference'计划”AsPartial“的要求。 If it this is something that bothers people, maybe we can prefix the requirements, such as 'Filter:{$filterName}' and 'Validator:{$validatorName}'如果这是困扰人们的东西,也许我们可以前缀的要求,如“过滤器:{$ filterName}”和“验证:{$ validatorName}”

    Yes closures are supported in 5.3.支持5.3是封。 The reason i have used closures in this instance is to allow the developers to supply custom requirement creators.我已经使用在这种情况下封的原因是为了让开发人员提供定制要求创作者。

  • 分享到:
    评论

    相关推荐

    Global site tag (gtag.js) - Google Analytics