(PECL mongo >= 0.8.0)
mongo_query — Performs a basic database query
Performs a database query, returning a database cursor that can be passed to mongo_has_next or mongo_next. It is highly suggested that users use MongoCollection's find() function instead, as it is basically a wrapper for this function that handles of the extensive parameter list for the user.
The database connection to use.
The database and collection name
The query to execute.
The number of documents to skip.
The maximum number of documents to return.
An array of fields and directions on which to sort.
An array of the fields of each document to return.
An array giving the database a query hint.
Returns a cursor to the resulting documents.
Beispiel #1 mongo_query() example
This example shows how to use a query to get a page of search results from the database.
<?php
$searchterm = "pandas";
$pagenum = 2;
$resultsPerPage = 10;
$conn = mongo_connect("localhost", true);
if (!$conn) {
die("Could not connect.");
}
$cursor = mongo_query($conn, "zoo.animals", array("name" => $searchterm), ($pagenum-1)*$resultsPerPage, $resultsPerPage, null, null, null);
?>
This returns results 11-20 of objects in the zoo.animals collection with the name field "panda".