Files
doc-fr/reference/yaz/examples.xml
Yannick Torres 5dd9dcaf68 Reviewed
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@328201 c90b9560-bf6c-de11-be94-00142212c4b1
2012-10-31 08:49:59 +00:00

102 lines
2.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: af4410a7e15898c3dbe83d6ea38246745ed9c6fb Maintainer: yannick Status: ready -->
<!-- Reviewed: yes Maintainer: yannick -->
<chapter xml:id="yaz.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<para>
PHP/YAZ garde les traces des connexions avec les cibles
(Z-Associations). Une ressource représente une connexion
à une cible.
</para>
<para>
Le script ci-dessous montre la fonctionnalité de recherche parallèle
de l'API. Lorsqu'appelée sans argument, elle affiche une requête ;
sinon, elle cherche la cible donnée dans le tableau
<literal>host</literal>.
</para>
<para>
<example>
<title>Recherche parallèle en utilisant Yaz</title>
<programlisting role="php">
<![CDATA[
<?php
$host=$_REQUEST[host];
$query=$_REQUEST[query];
$num_hosts = count($host);
if (empty($query) || count($host) == 0) {
echo '<form method="get">
<input type="checkbox"
name="host[]" value="bagel.indexdata.dk/gils" />
test GILS
<input type="checkbox"
name="host[]" value="localhost:9999/Default" />
test local
<input type="checkbox" checked="checked"
name="host[]" value="z3950.loc.gov:7090/voyager" />
Library of Congress
<br />
Requête RPN:
<input type="text" size="30" name="query" />
<input type="submit" name="action" value="Search" />
</form>
';
} else {
echo 'Votre recherche pour ' . htmlspecialchars($query) . '<br />';
for ($i = 0; $i < $num_hosts; $i++) {
$id[] = yaz_connect($host[$i]);
yaz_syntax($id[$i], "usmarc");
yaz_range($id[$i], 1, 10);
yaz_search($id[$i], "rpn", $query);
}
yaz_wait();
for ($i = 0; $i < $num_hosts; $i++) {
echo '<hr />' . $host[$i] . ':';
$error = yaz_error($id[$i]);
if (!empty($error)) {
echo "Erreur : $error";
} else {
$hits = yaz_hits($id[$i]);
echo "Nombre de résultat(s) : $hits";
}
echo '<dl>';
for ($p = 1; $p <= 10; $p++) {
$rec = yaz_record($id[$i], $p, "string");
if (empty($rec)) continue;
echo "<dt><b>$p</b></dt><dd>";
echo nl2br($rec);
echo "</dd>";
}
echo '</dl>';
}
}
?>
]]>
</programlisting>
</example>
</para>
</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:"~/.phpdoc/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
-->