Examples

Search Class API Examples

Example of an search using the control number as criteria. This is possibly the most useful example as searching for by the control number of an item is one of the most common searches in the Emilda code.


require_once "mgmnt.inc";
require_once "search.inc";

$search = new Search;
$search->search_by_cn("1234");

if (!$search->errno()) {
   while($record = $search->next(10)) {
      print $record->ffield("020", "This book has the ISBN number '%a'\n");
   }
} else {
   die "Failed!";
}

$search->terminate();

More complicated search using more details in the API


require_once "mgmnt.inc";
require_once "search.inc";

$search = new Search;
$ccl = $search->generate_ccl(array("100" => "Jansson"));
$rpn = $search->ccl2rpn($ccl, generate_ccl_conf());
$search->perform($rpn, "1=4 ai");

if (!$search->errno()) {
   while($record = $search->next(10)) {
      print $record->ffield("020", "This book has the ISBN number '%a'\n");
      printf("Raw MARC: %s\n", $search->additional("raw"));
   }
} else {
   die "Failed!";
}

$search->terminate();