<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >YAZ Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="xslt_setopt" HREF="function.xslt-setopt.html"><LINK REL="NEXT" TITLE="yaz_addinfo" HREF="function.yaz-addinfo.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.xslt-setopt.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.yaz-addinfo.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.yaz" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CLXXXV. YAZ Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN240512" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="yaz.intro" >Introdução</A ></H1 ><P > This extension offers a PHP interface to the <SPAN CLASS="productname" >YAZ</SPAN > toolkit that implements the <A HREF="http://www.loc.gov/z3950/agency/" TARGET="_top" >Z39.50 Protocol for Information Retrieval</A >. With this extension you can easily implement a Z39.50 origin (client) that searches or scans Z39.50 targets (servers) in parallel. </P ><P > The module hides most of the complexity of Z39.50 so it should be fairly easy to use. It supports persistent stateless connections very similar to those offered by the various RDB APIs that are available for PHP. This means that sessions are stateless but shared among users, thus saving the connect and initialize phase steps in most cases. </P ><P > <SPAN CLASS="productname" >YAZ</SPAN > is available at <A HREF="http://www.indexdata.dk/yaz/" TARGET="_top" >http://www.indexdata.dk/yaz/</A >. You can find news information, example scripts, etc. for this extension at <A HREF="http://www.indexdata.dk/phpyaz/" TARGET="_top" >http://www.indexdata.dk/phpyaz/</A >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > Esta extensão foi movida para o repositório <A HREF="http://pecl.php.net" TARGET="_top" >PECL</A > e não é mais distribuida em conjunto com o PHP a partir do PHP 5.0.0. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="yaz.installation" >Instalação</A ></H1 ><P > Obtain YAZ (ANSI/NISO Z39.50 support) and install it. YAZ can be fetched in source or in various prebuilt packages from the <A HREF="http://ftp.indexdata.dk/pub/yaz/" TARGET="_top" >YAZ archive</A >. Systems such as Debian GNU/Linux, Suse Linux, FreeBSD also has YAZ as part of their distribution. </P ><P > For the PHP 4 series, the YAZ extension is bundled (but not YAZ itself) Build PHP with your favorite modules and add option <CODE CLASS="option" >--with-yaz[=DIR]</CODE >. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN240532" ></A ><P ><B >Exemplo 1. YAZ compilation for PHP 4 on Unix</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="shell" >gunzip -c php-4.4.X.tar.gz|tar xf - gunzip -c yaz-2.1.8.tar.gz|tar xf - cd yaz-2.1.8 ./configure --prefix=/usr make sudo make install cd ../php-4.4.X. ./configure --with-yaz=/usr/bin make sudo make install</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > For PHP 5, the YAZ extension is in <A HREF="http://pecl.php.net" TARGET="_top" >PECL</A > and is installed as a shared object/dll. If you have pear installed the easiest way to download, configure and install the YAZ extension is by using the <B CLASS="command" >pecl</B > command. </P ><P > Installation of YAZ on Linux </P ><P > Informações para a instalação desta extensão PECL podem ser encontradas no manual no capitulo entitulado <A HREF="install.pecl.html" >Instalação de extensões PECL</A >. Informações adicionais como novas versões, downloads, arquivos fontes, manutenções, e um Changelog, podem ser obtidos aqui: <A HREF="http://pecl.php.netyaz" TARGET="_top" >http://pecl.php.netyaz</A > </P ><P > Installation on Windows systems </P ><P > Você pode baixar esta extensão <ACRONYM CLASS="acronym" >PECL</ACRONYM > <ACRONYM CLASS="acronym" >DLL</ACRONYM > a apartir de <A HREF="http://www.php.net/downloads.php" TARGET="_top" > downloads PHP</A > ou em <A HREF="http://snaps.php.net/" TARGET="_top" > http://snaps.php.net/</A >. <TT CLASS="filename" >php_yaz.dll</TT > depends on <TT CLASS="filename" >yaz.dll</TT >. The <TT CLASS="filename" >yaz.dll</TT > is part of the Win32 ZIP from the PHP site. It is also part of the Windows YAZ install available from the <A HREF="http://ftp.indexdata.dk/pub/yaz/win32/" TARGET="_top" >YAZ WIN32 area</A >. </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Atenção</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > The PHP 5.0.5 Win32 zip includes a too old version of <TT CLASS="filename" >yaz.dll</TT > (version 1.9.1 < required version 2.0.13). If that's the case use the <TT CLASS="filename" >yaz.dll</TT > from a newer <A HREF="http://ftp.indexdata.dk/pub/yaz/win32/" TARGET="_top" >YAZ WIN32 install</A >. </P ></TD ></TR ></TABLE ></DIV ><P > On windows, don't forget to add the PHP directory to the PATH, so that the <TT CLASS="filename" >yaz.dll</TT > file can be found by the system. </P ><P > If you are using YAZ as a shared extension, add (or uncomment) the following line in <TT CLASS="filename" >php.ini</TT > on Unix: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >extension=yaz.so</PRE ></TD ></TR ></TABLE > And for Windows: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >extension=php_yaz.dll</PRE ></TD ></TR ></TABLE > </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Atenção</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P >A extensão <A HREF="ref.imap.html" >IMAP</A > não pode ser utilizada em conjunto com as extensões <A HREF="ref.recode.html" >recode</A >, <A HREF="ref.yaz.html" >YAZ</A > ou <A HREF="ref.cyrus.html" >Cyrus</A >. Isto ocorre pelo fato de elas compartilham os mesmos símbolos internos.</P ></TD ></TR ></TABLE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > The above problem is solved in version 2.0 of YAZ. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="yaz.configuration" >Configurações em execução</A ></H1 ><P > O comportamento dessas funções podem ser modificado pelas configurações do <TT CLASS="filename" >php.ini</TT >. </P ><P > <DIV CLASS="table" ><A NAME="AEN240576" ></A ><P ><B >Tabela 1. YAZ configuration options</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><COL><THEAD ><TR ><TH >Name</TH ><TH >Default</TH ><TH >Changeable</TH ><TH >Changelog</TH ></TR ></THEAD ><TBODY ><TR ><TD >yaz.max_links</TD ><TD >"100"</TD ><TD >PHP_INI_ALL</TD ><TD >Available since PHP 4.3.0.</TD ></TR ><TR ><TD >yaz.log_file</TD ><TD >NULL</TD ><TD >PHP_INI_ALL</TD ><TD >Available since PHP 4.3.0.</TD ></TR ></TBODY ></TABLE ></DIV > Para mais detalhes e definições das constantes PHP_INI_*, veja <A HREF="ini.html" >Apêndice H</A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="yaz.resources" >Tipos Resource</A ></H1 ><P >Esta extensão não possui nenhum tipo resource.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="yaz.constants" >Constantes pré-definidas</A ></H1 ><P >Esta extensão não possui nenhuma constante.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="yaz.examples" >Exemplos</A ></H1 ><P > PHP/YAZ keeps track of connections with targets (Z-Associations). A resource represents a connection to a target. </P ><P > The script below demonstrates the parallel searching feature of the API. When invoked with no arguments it prints a query form; else (arguments are supplied) it searches the targets as given in array <TT CLASS="literal" >host</TT >. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN240609" ></A ><P ><B >Exemplo 2. Parallel searching using Yaz</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$host</font><font color="#007700">=</font><font color="#0000BB">$_REQUEST</font><font color="#007700">[</font><font color="#0000BB">host</font><font color="#007700">];<br /></font><font color="#0000BB">$query</font><font color="#007700">=</font><font color="#0000BB">$_REQUEST</font><font color="#007700">[</font><font color="#0000BB">query</font><font color="#007700">];<br /></font><font color="#0000BB">$num_hosts </font><font color="#007700">= </font><font color="#0000BB">count</font><font color="#007700">(</font><font color="#0000BB">$host</font><font color="#007700">);<br />if (empty(</font><font color="#0000BB">$query</font><font color="#007700">) || </font><font color="#0000BB">count</font><font color="#007700">(</font><font color="#0000BB">$host</font><font color="#007700">) == </font><font color="#0000BB">0</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">'<form method="get"><br /> <input type="checkbox"<br /> name="host[]" value="bagel.indexdata.dk/gils" /><br /> GILS test<br /> <input type="checkbox"<br /> name="host[]" value="localhost:9999/Default" /><br /> local test<br /> <input type="checkbox" checked="checked"<br /> name="host[]" value="z3950.loc.gov:7090/voyager" /><br /> Library of Congress<br /> <br /><br /> RPN Query:<br /> <input type="text" size="30" name="query" /><br /> <input type="submit" name="action" value="Search" /><br /> </form><br /> '</font><font color="#007700">; <br />} else {<br /> echo </font><font color="#DD0000">'You searched for ' </font><font color="#007700">. </font><font color="#0000BB">htmlspecialchars</font><font color="#007700">(</font><font color="#0000BB">$query</font><font color="#007700">) . </font><font color="#DD0000">'<br />'</font><font color="#007700">;<br /> for (</font><font color="#0000BB">$i </font><font color="#007700">= </font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$i </font><font color="#007700">< </font><font color="#0000BB">$num_hosts</font><font color="#007700">; </font><font color="#0000BB">$i</font><font color="#007700">++) {<br /> </font><font color="#0000BB">$id</font><font color="#007700">[] = </font><font color="#0000BB">yaz_connect</font><font color="#007700">(</font><font color="#0000BB">$host</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]);<br /> </font><font color="#0000BB">yaz_syntax</font><font color="#007700">(</font><font color="#0000BB">$id</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">], </font><font color="#DD0000">"usmarc"</font><font color="#007700">);<br /> </font><font color="#0000BB">yaz_range</font><font color="#007700">(</font><font color="#0000BB">$id</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">], </font><font color="#0000BB">1</font><font color="#007700">, </font><font color="#0000BB">10</font><font color="#007700">);<br /> </font><font color="#0000BB">yaz_search</font><font color="#007700">(</font><font color="#0000BB">$id</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">], </font><font color="#DD0000">"rpn"</font><font color="#007700">, </font><font color="#0000BB">$query</font><font color="#007700">);<br /> }<br /> </font><font color="#0000BB">yaz_wait</font><font color="#007700">();<br /> for (</font><font color="#0000BB">$i </font><font color="#007700">= </font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$i </font><font color="#007700">< </font><font color="#0000BB">$num_hosts</font><font color="#007700">; </font><font color="#0000BB">$i</font><font color="#007700">++) {<br /> echo </font><font color="#DD0000">'<hr />' </font><font color="#007700">. </font><font color="#0000BB">$host</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">] . </font><font color="#DD0000">':'</font><font color="#007700">;<br /> </font><font color="#0000BB">$error </font><font color="#007700">= </font><font color="#0000BB">yaz_error</font><font color="#007700">(</font><font color="#0000BB">$id</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]);<br /> if (!empty(</font><font color="#0000BB">$error</font><font color="#007700">)) {<br /> echo </font><font color="#DD0000">"Error: $error"</font><font color="#007700">;<br /> } else {<br /> </font><font color="#0000BB">$hits </font><font color="#007700">= </font><font color="#0000BB">yaz_hits</font><font color="#007700">(</font><font color="#0000BB">$id</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]);<br /> echo </font><font color="#DD0000">"Result Count $hits"</font><font color="#007700">;<br /> }<br /> echo </font><font color="#DD0000">'<dl>'</font><font color="#007700">;<br /> for (</font><font color="#0000BB">$p </font><font color="#007700">= </font><font color="#0000BB">1</font><font color="#007700">; </font><font color="#0000BB">$p </font><font color="#007700"><= </font><font color="#0000BB">10</font><font color="#007700">; </font><font color="#0000BB">$p</font><font color="#007700">++) {<br /> </font><font color="#0000BB">$rec </font><font color="#007700">= </font><font color="#0000BB">yaz_record</font><font color="#007700">(</font><font color="#0000BB">$id</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">], </font><font color="#0000BB">$p</font><font color="#007700">, </font><font color="#DD0000">"string"</font><font color="#007700">);<br /> if (empty(</font><font color="#0000BB">$rec</font><font color="#007700">)) continue;<br /> echo </font><font color="#DD0000">"<dt><b>$p</b></dt><dd>"</font><font color="#007700">;<br /> echo </font><font color="#0000BB">nl2br</font><font color="#007700">(</font><font color="#0000BB">$rec</font><font color="#007700">);<br /> echo </font><font color="#DD0000">"</dd>"</font><font color="#007700">;<br /> }<br /> echo </font><font color="#DD0000">'</dl>'</font><font color="#007700">;<br /> }<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.yaz-addinfo.html" >yaz_addinfo</A > -- Returns additional error information</DT ><DT ><A HREF="function.yaz-ccl-conf.html" >yaz_ccl_conf</A > -- Configure CCL parser</DT ><DT ><A HREF="function.yaz-ccl-parse.html" >yaz_ccl_parse</A > -- Invoke CCL Parser</DT ><DT ><A HREF="function.yaz-close.html" >yaz_close</A > -- Close YAZ connection</DT ><DT ><A HREF="function.yaz-connect.html" >yaz_connect</A > -- Prepares for a connection to a Z39.50 server </DT ><DT ><A HREF="function.yaz-database.html" >yaz_database</A > -- Specifies the databases within a session </DT ><DT ><A HREF="function.yaz-element.html" >yaz_element</A > -- Specifies Element-Set Name for retrieval </DT ><DT ><A HREF="function.yaz-errno.html" >yaz_errno</A > -- Returns error number</DT ><DT ><A HREF="function.yaz-error.html" >yaz_error</A > -- Returns error description</DT ><DT ><A HREF="function.yaz-es-result.html" >yaz_es_result</A > -- Inspects Extended Services Result </DT ><DT ><A HREF="function.yaz-es.html" >yaz_es</A > -- Prepares for an Extended Service Request </DT ><DT ><A HREF="function.yaz-get-option.html" >yaz_get_option</A > -- Returns value of option for connection</DT ><DT ><A HREF="function.yaz-hits.html" >yaz_hits</A > -- Returns number of hits for last search</DT ><DT ><A HREF="function.yaz-itemorder.html" >yaz_itemorder</A > -- Prepares for Z39.50 Item Order with an ILL-Request package </DT ><DT ><A HREF="function.yaz-present.html" >yaz_present</A > -- Prepares for retrieval (Z39.50 present) </DT ><DT ><A HREF="function.yaz-range.html" >yaz_range</A > -- Specifies a range of records to retrieve </DT ><DT ><A HREF="function.yaz-record.html" >yaz_record</A > -- Returns a record</DT ><DT ><A HREF="function.yaz-scan-result.html" >yaz_scan_result</A > -- Returns Scan Response result</DT ><DT ><A HREF="function.yaz-scan.html" >yaz_scan</A > -- Prepares for a scan</DT ><DT ><A HREF="function.yaz-schema.html" >yaz_schema</A > -- Specifies schema for retrieval </DT ><DT ><A HREF="function.yaz-search.html" >yaz_search</A > -- Prepares for a search</DT ><DT ><A HREF="function.yaz-set-option.html" >yaz_set_option</A > -- Sets one or more options for connection</DT ><DT ><A HREF="function.yaz-sort.html" >yaz_sort</A > -- Sets sorting criteria</DT ><DT ><A HREF="function.yaz-syntax.html" >yaz_syntax</A > -- Specifies the preferred record syntax for retrieval </DT ><DT ><A HREF="function.yaz-wait.html" >yaz_wait</A > -- Wait for Z39.50 requests to complete</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.xslt-setopt.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.yaz-addinfo.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >xslt_setopt</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >yaz_addinfo</TD ></TR ></TABLE ></DIV ></BODY ></HTML >