Subject RE: [firebird-php] Re: Search Engine
Author Nigel Weeks
Depends on what you need.
If the number of records is small, you can get away with doing a simple
'containing' search like the following:

--------- search.php ---------
<?php

// WARNING - no sanity checking is done on this 'search' variable, and will
thusly allow HTML through

$conn = ibase_connect("server:/path/to/database.fdb","sysdba","masterkey");

echo "<html><head><title>Search</title></head><body><form method=post><input
type=text name='search' value='".$_GET['search']. "'><input type=submit
value='Go'></form>";

if($_GET['search'] != ""){

// Make it safe for Firebird queries
$search = str_replace("'","''",$_GET['search']);

// Prepare the query, putting real fields in the string instead

$sql = "select * from table where some_field containing '".$search."' or
another_field containing '".$search."'";
echo "Query about to be performed '".$sql."'<br>";

// Run the query
$rec = ibase_query($sql);

// echo out the beginning of the table
echo "<table><tr><td><b>Some Field</b></td><td><b>Another
Field</b></td></tr>";
while($obj = ibase_fetch_row($rec)){
echo
"<tr><td>".$obj->SOME_FIELD."</td><td>".$obj->ANOTHER_FIELD."</td></tr>";
} // End of while loop

// echo out the end of the table
echo "</table></body></html>";
} // End of if $_GET['search'] has been supplied

?>
-------------- end of search.php -----------

If your records are bigger, you're going to have to look at different
methods, like chopping fields into individual words, and creating lookup
tables, soundex matching, etc.
There's lots of resources on full-text searches - have a quick look through
the archives for some really snazzy ideas!

Nige.




-----Original Message-----
From: firebird-php@yahoogroups.com [mailto:firebird-php@yahoogroups.com]On
Behalf Of Almond
Sent: Friday, 24 November 2006 3:11 PM
To: firebird-php@yahoogroups.com; firebird-php@yahoogroups.com
Subject: Re: [firebird-php] Re: Search Engine


Thank you for your help. I think I not made my question clear.

I try to build a knowledge base with search feature. So, I need to build a
search engine on user entered data inside a firebird database, i.e. inside
blob text, keyword, etc.

Regards,

Almond Wong

At 2006-11-24 01:09, Myles Wakeham wrote:

> > Anybody know there are some kind of search engine in PHP and
> > support
> > Chinese language ?
>
>Why don't you just use SOAP WebServices and integrate directly with
>Google.com for this? I mean using NuSOAP or native PHP5 SOAP Web Client
>services, you can simply subscribe directly to Google.com and pass the
>search to them as a webservice request, and then format the results and
>display them in your PHP5 application.
>
>Do a 'Google' search for Google's web services API and you'll be set.
>
>Regards,
>Myles
>
>===============================
>Myles Wakeham
>Director of Engineering
>Tech Solutions US, Inc.
>Phone (480) 451-7440
>www.techsol.org
>
>






[Non-text portions of this message have been removed]