mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-30 15:58:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@276457 c90b9560-bf6c-de11-be94-00142212c4b1
176 lines
4.6 KiB
XML
176 lines
4.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.4 $ -->
|
|
|
|
<refentry xml:id="function.mongo-query" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>mongo_query</refname>
|
|
<refpurpose>Performs a basic database query</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>resource</type><methodname>mongo_query</methodname>
|
|
<methodparam><type>resource</type><parameter>connection</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>ns</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>query</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>skip</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>limit</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>sort</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>fields</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>hint</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
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.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>connection</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The database connection to use.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>ns</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The database and collection name
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>query</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The query to execute.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>skip</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The number of documents to skip.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>limit</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The maximum number of documents to return.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>sort</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
An array of fields and directions on which to sort.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>fields</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
An array of the fields of each document to return.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>hint</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
An array giving the database a query hint.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns a cursor to the resulting documents.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>mongo_query</function> example</title>
|
|
<para>
|
|
This example shows how to use a query to get a page of
|
|
search results from the database.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
This returns results 11-20 of objects in the zoo.animals collection with the name field "panda".
|
|
</para>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>mongo_has_next</function></member>
|
|
<member><function>mongo_next</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|