PHP Handbuch
Zurück |  | Nach vorne

# yaz_scan

(PHP 4 >= 4.0.5)

yaz_scan -- Prepares for a scan

## Description

int yaz_scan ( int id, string type, string startterm [, array flags])

This function prepares for a Z39.50 Scan Request. Argument `id` specifies target ID. Starting term point for the scan is given by `startterm`. The form in which is the starting term is specified is given by `type`. Currently type `rpn` is supported. The optional `flags` specifies additional information to control the behaviour of the scan request. Three indexes are currently read from the flags: `number` (number of terms requested), `position` (preferred position of term) and `stepSize` (preferred step size). To actually tranfer the Scan Request to the target and receive the Scan Response, yaz_wait() must be called. Upon completion of yaz_wait() call yaz_error() and yaz_scan_result() to handle the response.

The syntax of `startterm` is similar to the RPN query as described in yaz_search(). The startterm consists of zero or more `@attr`-operator specifications, then followed by exactly one token.

Beispiel 1. PHP function that scans titles
    function scan_titles($id, $starterm) {
            yaz_scan($id,"rpn", "@attr 1=4 " . $starterm);
            yaz_wait();
            $errno = yaz_errno($id);
            if ($errno == 0) {
              $ar = yaz_scan_result($id,&$options);
              echo 'Scan ok; ';
              $ar = yaz_scan_result($id, &$options);
              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>";
            }
          }

Zurück | Zum Anfang | Nach vorne
yaz_scan_result | Nach oben | yaz_search