Harvester316
Harvester316

Reputation: 379

Why do I get slaveOkay = 0; Timeout = 30000 MongoPHP

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.

Upvotes: 0

Views: 69

Answers (1)

bjori
bjori

Reputation: 2104

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

Upvotes: 0

Related Questions