coen-hyde / Shanty-Mongo

Shanty Mongo is a mongodb library for the Zend Framework. Its intention is to make working with mongodb documents as natural and as simple as possible. In particular allowing embedded documents to also have custom document classes.
Other
200 stars 52 forks source link

Collection all() failing #48

Closed zapatista closed 12 years ago

zapatista commented 12 years ago

class Application_Model_Db_Table_Post extends Shanty_Mongo_Document { protected static $_db = 'holemp'; protected static $_collection = 'user'; }

$user = Application_Model_Db_Table_Post::all();

why not work on me ?

output: Shanty_Mongo_Iterator_Cursor Object ( [_cursor:protected] => MongoCursor Object ( )

[_config:protected] => Array
    (
        [connectionGroup] => default
        [db] => holemp
        [collection] => user
        [documentClass] => Application_Model_Db_Table_Post
        [documentSetClass] => Shanty_Mongo_DocumentSet
    )

)

tholder commented 12 years ago

You know all returns a DocumentSet not a Document? You need to iterate over it to get the individual documents.

coen-hyde commented 12 years ago

Tom is correct. You need to iterate over the cursor to fetch the documents from the database.