[Xapian-discuss] PHP Binding and dbi2omega questions

Olly Betts olly at survex.com
Fri Feb 9 19:19:32 GMT 2007


On Fri, Feb 09, 2007 at 04:22:59PM +0000, James Aylett wrote:
> No; the convention (used by omega via omindex and scriptindex) of
> name=value pairs isn't required by Xapian itself, so isn't supported
> directly in the bindings. It is reasonably easy to write helper
> functions, although with PHP it's not terribly convenient to make it
> pretty.

The cleanest way is probably just to turn the document data into an
associative array which you can then lookup to find the field you
want:

    <?
    $docdata = "a=b\nurl=foo\nhello=test=test";

    foreach (split("\n", $docdata) as $line) {
	$nameval = split("=", $line, 2);
	$field[$nameval[0]] = $nameval[1];
    }

    print "The url is $field[url]\n";

    foreach ($field as $key => $val) {
	print "$key -> $val\n";
    }
    ?>

Cheers,
    Olly



More information about the Xapian-discuss mailing list