0
votes

I am using Mac, netbeans, x-debug, with Mongo PHP. I am trying to run a basic search like:

$results = $mongo->$col->find();

However during debug, the value for $results is slaveOkay = 0 and timeout = 30000. Why is this so? Some version information about the tools installed are:

PHP 5.4.20 (cli) (built: Sep 24 2013 10:10:10) (DEBUG) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

MongoDB shell version: 2.4.6

Thanks.

1
These appear to be values that belong to the driver to manage itself... how exactly do these values look like? Can you iterate the actual result set?mnemosyn
No, there is nothing else in property $results besides: slaveOkay boolean 0 and timeout 30000. No other results and no errors either. Those values are just what I see under debug mode in $results variable.Harvester316

1 Answers

0
votes

Where does that $col variable come from? And where does $mongo come from?

The correct way to query a collection is

<?php
$mongo = new MongoClient(...);
$collection = $mongo->databaseName->collectionName;
$results = $collection->find();
?>

Then you can iterate over $results like so:

foreach($results as $document) {
    /* Do something with $document */
}

See http://php.net/mongocollection.find and http://php.net/mongo.queries for more details