Problem With Querying

45 views
Skip to first unread message

Neil Charlton

unread,
Sep 2, 2011, 9:50:31 PM9/2/11
to YiiMongoDbSuite
I'm successfully using version 1.3 to save to my MongoDb, so I know
its not a connectivity or other similar issue.

For some reason there seems to be a problem with querying

From the shell (version 1.8.2). If I use

$ db.products.find();
{ "_id" : ObjectId("4e60e0ccc0da53707c000000"), "display_title" :
"test", "price" : "100" }
{ "_id" : ObjectId("4e617cebc0da538f72000000"), "display_title" :
"test 2", "price" : "50" }
{ "_id" : ObjectId("4e617d2cc0da53b279000000"), "display_title" :
"test 3", "price" : "120" }

I know that I have 3 documents in this collection.

Using YiiMongoDbSuite from my controller I use this

$model = Product::model()->findAll();
print_r($model);

and I get

Array
(
[0] => Product Object
(
[display_title] =>
[price] =>
[_new:EMongoDocument:private] =>
[_criteria:EMongoDocument:private] =>
[_fsyncFlag:EMongoDocument:private] =>
[_safeFlag:EMongoDocument:private] =>
[useCursor:protected] =>
[ensureIndexes:protected] => 1
[_id] =>
[_embedded:protected] =>
[_owner:protected] =>
[_errors:CModel:private] => Array
(
)

[_validators:CModel:private] =>
[_scenario:CModel:private] => update
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)

[1] => Product Object
(
[display_title] =>
[price] =>
[_new:EMongoDocument:private] =>
[_criteria:EMongoDocument:private] =>
[_fsyncFlag:EMongoDocument:private] =>
[_safeFlag:EMongoDocument:private] =>
[useCursor:protected] =>
[ensureIndexes:protected] => 1
[_id] =>
[_embedded:protected] =>
[_owner:protected] =>
[_errors:CModel:private] => Array
(
)

[_validators:CModel:private] =>
[_scenario:CModel:private] => update
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
[2] => Product Object
(
[display_title] =>
[price] =>
[_new:EMongoDocument:private] =>
[_criteria:EMongoDocument:private] =>
[_fsyncFlag:EMongoDocument:private] =>
[_safeFlag:EMongoDocument:private] =>
[useCursor:protected] =>
[ensureIndexes:protected] => 1
[_id] =>
[_embedded:protected] =>
[_owner:protected] =>
[_errors:CModel:private] => Array
(
)

[_validators:CModel:private] =>
[_scenario:CModel:private] => update
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
)

So it is returning the correct number of documents (3) but there is no
data in there. Does anyone know how to fix this?


Neil Charlton

unread,
Sep 2, 2011, 10:38:06 PM9/2/11
to YiiMongoDbSuite
I just wanted to say I'm using the latest version of YiiMongoDbSuite
not 1.3 (sorry).

Attila Nagy

unread,
Sep 5, 2011, 11:18:30 AM9/5/11
to yiimong...@googlegroups.com
Could you please post how is your "Product" class defined? Maybe you
missed something there.

--
Nagy Attila Gabor

Reply all
Reply to author
Forward
0 new messages