<HTML ><HEAD ><TITLE >yaz_scan</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="YAZ functions" HREF="ref.yaz.html"><LINK REL="PREVIOUS" TITLE="yaz_scan_result" HREF="function.yaz-scan-result.html"><LINK REL="NEXT" TITLE="yaz_schema" HREF="function.yaz-schema.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" 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" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.yaz-scan-result.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.yaz-schema.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.yaz-scan" ></A >yaz_scan</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN97887" ></A ><P > (PHP 4 >= 4.0.5)</P >yaz_scan -- Prepares for a scan</DIV ><DIV CLASS="refsect1" ><A NAME="AEN97890" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >yaz_scan</B > ( resource id, string type, string startterm [, array flags])<BR ></BR ><P > This function prepares for a Z39.50 Scan Request. Argument <TT CLASS="parameter" ><I >id</I ></TT > specifies connection. Starting term point for the scan is given by <TT CLASS="parameter" ><I >startterm</I ></TT >. The form in which is the starting term is specified is given by <TT CLASS="parameter" ><I >type</I ></TT >. Currently type <TT CLASS="literal" >rpn</TT > is supported. The optional <TT CLASS="parameter" ><I >flags</I ></TT > specifies additional information to control the behaviour of the scan request. Three indexes are currently read from the flags: <TT CLASS="literal" >number</TT > (number of terms requested), <TT CLASS="literal" >position</TT > (preferred position of term) and <TT CLASS="literal" >stepSize</TT > (preferred step size). To actually tranfer the Scan Request to the target and receive the Scan Response, <A HREF="function.yaz-wait.html" ><B CLASS="function" >yaz_wait()</B ></A > must be called. Upon completion of <A HREF="function.yaz-wait.html" ><B CLASS="function" >yaz_wait()</B ></A > call <A HREF="function.yaz-error.html" ><B CLASS="function" >yaz_error()</B ></A > and <A HREF="function.yaz-scan-result.html" ><B CLASS="function" >yaz_scan_result()</B ></A > to handle the response. </P ><P > The syntax of <TT CLASS="parameter" ><I >startterm</I ></TT > is similar to the RPN query as described in <A HREF="function.yaz-search.html" ><B CLASS="function" >yaz_search()</B ></A >. The startterm consists of zero or more <TT CLASS="literal" >@attr</TT >-operator specifications, then followed by exactly one token. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN97925" ></A ><P ><B >Example 1. PHP function that scans titles</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" >function scan_titles($id, $startterm) { yaz_scan($id,"rpn", "@attr 1=4 " . $startterm); yaz_wait(); $errno = yaz_errno($id); if ($errno == 0) { $ar = yaz_scan_result($id,&$options); echo 'Scan ok; '; while(list($key,$val)=each($options)) { echo "$key = $val &nbsp;"; } echo '<br><table><tr><td>'; while(list($key,list($k, $term, $tcount))=each($ar)) { if (empty($k)) continue; echo "<tr><td>$term</td><td>"; echo $tcount; echo "</td></tr>"; } echo '</table>'; } else { echo "Scan failed. Error: " . yaz_error($id) . "<br>"; } }</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></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.yaz-scan-result.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.yaz-schema.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >yaz_scan_result</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.yaz.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >yaz_schema</TD ></TR ></TABLE ></DIV ></BODY ></HTML >