CVIII. YAZ functions

Introduction

이 익스텐션은 정보검색을 위한 Z39.50 프로토콜을 사용하는YAZ툴킷의 PHP 인터페이스를 제공한다. 이 익스텐션은 Z39.50 origin(client)에게 쉽게 Z39.50 targets (servers)을 병렬 검색할 수 있는 도구를 제공한다.

YAZhttp://www.indexdata.dk/yaz/서 만나볼 수 있다. 뉴스, 예제 스크립트, 등등 이 익스텐션은 http://www.indexdata.dk/phpyaz/여기서 구할 수 있다.

이 모듈은 Z39.50의 복잡성은 대부분 감추어져 있어서 매우 사용하기 쉽다. 이것은 PHP가 이용할 수 있는 다양한 SQL APIs와 매우 유사한 persistent stateless connections 을 제공한다. 이것은 세션들이 stateless 하지만 사용자들에게 분배된다는 것을 의미한다. 결국. 대부분의 경우 연결은 저장되고 상태의 진행은 초기화 된다.

설치

YAZ를 컴파일 하고 설치를 한다. PHP를 필요한 모듈과 빌드 할때 --with-yaz 옵션을 추가한다. 작업은 대개 다음과 같다.:

gunzip -c yaz-1.6.tar.gz|tar xf -
gunzip -c php-4.0.X.tar.gz|tar xf -
cd yaz-1.6
./configure --prefix=/usr
make
make install
cd ../php-4.0.X
./configure --with-yaz=/usr/bin
make
make install

Example

PHP/YAZ는 targets(Z-Associations)의 연결을 유지한다. positive integer는 ID of a particular를 나타낸다.

아래의 예제 스크립트는 API의 parallel searching을 보여준다. 독립변수 업시 불러낼때 query form을 출력하고 그렇지 않은경우(독립변수가 주어질때) 주어진 배열에서 targets을 찾아낸다

예 1. YAZ()

$num_hosts = count ($host);
if (empty($term) || count($host) == 0) {
    echo '<form method="get">
    <input type="checkbox"
    name="host[]" value="bagel.indexdata.dk/gils">
        GILS test
    <input type="checkbox"
    name="host[]" value="localhost:9999/Default">
        local test
    <input type="checkbox" checked="1"
    name="host[]" value="z3950.bell-labs.com/books">
        BELL Labs Library
    <br>
    RPN Query:
    <input type="text" size="30" name="term">
    <input type="submit" name="action" value="Search">
    ';        
} else {
    echo 'You searced for ' . htmlspecialchars($term) . '<br>';
    for ($i = 0; $i < $num_hosts; $i++) {
        $id[] = yaz_connect($host[$i]);
        yaz_syntax($id[$i],"sutrs");
        yaz_search($id[$i],"rpn",$term);
    }
    yaz_wait();
    for ($i = 0; $i < $num_hosts; $i++) {
        echo '<hr>' . $host[$i] . ":";
        $error = yaz_error($id[$i]);
        if (!empty($error)) {
            echo "Error: $error";
        } else {
            $hits = yaz_hits($id[$i]);
            echo "Result Count $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 ereg_replace("\n", "<br>\n",$rec);
            echo "</dd>";
        }
        echo '</dl>';
    }
}

차례
yaz_addinfo -- 추가적인 error 정보를 리턴한다.
yaz_ccl_conf -- Configure CCL parser
yaz_ccl_parse -- Invoke CCL Parser
yaz_close -- YAZ의 연결을 닫는다.
yaz_connect --  성공한 경우 양의 association ID를 리턴한다 : 실패의 경우 "0"을 리턴
yaz_database --  Specifies the databases within a session
yaz_element --  Specifies Element-Set Name for retrieval
yaz_errno -- error number를 리턴한다.
yaz_error -- error내용을 리턴한다.
yaz_hits -- 마지막 검색에 대한 히트수를 리턴한다.
yaz_itemorder --  Prepares for Z39.50 Item Order with an ILL-Request package
yaz_present --  Prepares for retrieval (Z39.50 present).
yaz_range --  검색결과를 나타낼 범위를 지정한다.
yaz_record -- 레코드를 리턴한다.
yaz_scan_result -- Returns Scan Response result
yaz_scan -- Prepares for a scan
yaz_search -- 검색을 준비한다.
yaz_sort -- Sets sorting criteria
yaz_syntax --  Specifies the object identifier (OID) for the preferred record syntax for retrieval.
yaz_wait -- Executes queries