mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-29 04:12:21 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@276493 c90b9560-bf6c-de11-be94-00142212c4b1
82 lines
1.7 KiB
XML
82 lines
1.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.2 $ -->
|
|
<!-- EN-Revision: 1.3 Maintainer: dams Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<chapter xml:id="mongo.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
&reftitle.examples;
|
|
<para>
|
|
Cet exemple montre comment se connecter, insérer un objet,
|
|
demander un autre objet, et passer en revue les résultats
|
|
de requête, puis se déconnecter.
|
|
</para>
|
|
<example>
|
|
<title>Exemple Mongo</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
include "mongo.php";
|
|
|
|
// connexion
|
|
$m = new Mongo();
|
|
|
|
// selection d'une base
|
|
$db = $m->selectDatabase("comedy");
|
|
$collection = $db->selectCollection("cartoons");
|
|
|
|
// Ajout d'un élément
|
|
$obj = array( "title" => "Calvin and Hobbes", "author" => "Bill Watterson" );
|
|
$collection->insert($obj);
|
|
|
|
// Ajout d'un aute élément, avec une autre forme
|
|
$obj = array( "title" => "XKCD", "online" => true );
|
|
$collection->insert($obj);
|
|
|
|
// lecture de toute la collection
|
|
$cursor = $collection->find();
|
|
|
|
// revue des résultats
|
|
while( $cursor->hasNext() ) {
|
|
$c = $cursor->next();
|
|
echo $c["title"] . "\n";
|
|
}
|
|
|
|
// déconnexion
|
|
$m->close();
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
Calvin and Hobbes
|
|
XKCD
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</chapter>
|
|
|
|
<!-- 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
|
|
-->
|
|
|