Files
archived-doc-pt-br/reference/yaz/examples.xml
Fernando Wobeto d150c33819 Tradução em reference/yaz (#711)
* inclusão dos arquivos originais com revisão atualizada

* Tradução em reference/yaz
2024-12-16 10:43:55 -03:00

100 lines
2.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: af4410a7e15898c3dbe83d6ea38246745ed9c6fb Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<chapter xml:id="yaz.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<para>
PHP/YAZ mantém o controle de conexões com alvos
(Z-Associations). Um recurso representa uma conexão com um
alvo.
</para>
<para>
O script abaixo demonstra o recurso de pesquisa paralela da
API. Quando invocado sem argumentos, ele imprime um formulário de consulta; senão
(os argumentos são fornecidos) ele pesquisa os alvos conforme fornecido no array
<literal>host</literal>.
</para>
<para>
<example>
<title>Pesquisa paralela usando 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" />
Teste GILS
<input type="checkbox"
name="host[]" value="localhost:9999/Default" />
Teste local
<input type="checkbox" checked="checked"
name="host[]" value="z3950.loc.gov:7090/voyager" />
Biblioteca do Congresso
<br />
Consulta RPN:
<input type="text" size="30" name="query" />
<input type="submit" name="action" value="Pesquisar" />
</form>
';
} else {
echo 'Você pesquisou por ' . 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 "Erro: $error";
} else {
$hits = yaz_hits($id[$i]);
echo "Contagem de resultados $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
-->