Login   Register  
PHP Classes
elePHPant
Icontem

File: class_odbcsearch

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Frits Bergman  >  OdbcSearch  >  class_odbcsearch  >  Download  
File: class_odbcsearch
Role: Class source
Content type: text/plain
Description: Search-engine for ODBC-connected databases
Class: OdbcSearch
ODBC-Database search-engine
Author: By
Last change: name gone
Date: 9 years ago
Size: 3,057 bytes
 

Contents

Class file image Download
<?php

class OdbcSearch
{
    
// description: Search-component, can search with one simple sql-query.
    // version:     1.4
    // history:     14-04-2002 v1.0 release
    //              04-05-2002 v1.1 jumppage_table
    //              06-11-2002 v1.2 jump_table removed, extra href-param added
    //              13-11-2002 v1.3 outputcount added, multiple searchwords added
    //              05-08-2003 v1.4 one result redirect
    //              03-12-2003 v1.5 SQLExpansion
    
    
var $Connection;
    var 
$Trefwoord;
    var 
$ColumnArray = array();                // Holds the columns to search (use AddColumn)
    
var $Font_face "Arial,Helvetica";
    var 
$Font_size 2;
    var 
$CategoryVar "gevonden in ";
    var 
$SubCategoryVar ",";
    var 
$OutputCounter 0;

    function 
OdbcSearch($Trefwoord)
    {
        
$this->Trefwoord $Trefwoord;
    }

    function 
Show()
    {
        
// Trefwoorden ontleden
        
$Woordenlijst explode(" ",$this->Trefwoord);
        for (
$j 0$j count($Woordenlijst); $j++)
        {    
            if (
$Woordenlijst[$j] != "")
            {
                for (
$i 0$i count($this->ColumnArray); $i++)
                {
                    
// Maak query met array-waarden
                    
if ($this->ColumnArray[$i][4] != ""$ExtraSQL ",".$this->ColumnArray[$i][4];
                    
$query "select ".$this->ColumnArray[$i][2].",".$this->ColumnArray[$i][1].$ExtraSQL." from ".$this->ColumnArray[$i][0]." where ".$this->ColumnArray[$i][1]." like '%".$Woordenlijst[$j]."%'".$this->ColumnArray[$i][5];
                    
$result odbc_exec($this->Connection,$query);

                    
// Output
                    
print"<font face=".$this->Font_face." size=".$this->Font_size.">";
                    while(
odbc_fetch_row($result))
                    {
                        
// Haal database velden
                        
$showstring odbc_result($result,$this->ColumnArray[$i][1]);
                        
$send_id odbc_result($result,$this->ColumnArray[$i][2]);

                        
// Zoek trefwoord in gevonden string nu met PHP ipv SQL-like.
                        
$upstring strtoupper($showstring);
                        
$uptrefwoord strtoupper($this->Trefwoord);
                        
$pos strpos($upstring,$uptrefwoord);
                        
$deelshowstring substr($showstring,$pos,20);

                        
// Maak totale output-string met HREF
                        
if ($this->ColumnArray[$i][4] != ""$extrastring odbc_result($result,$this->ColumnArray[$i][4]);
                        print 
$extrastring." ";
                        print 
"<a href=".$this->ColumnArray[$i][3].$send_id.">".$deelshowstring."</a> ".$this->CategoryVar.$this->ColumnArray[$i][0].$this->SubCategoryVar.$this->ColumnArray[$i][1]."<br>";
                        print
"<br>";
                        
$this->OutputCounter++;            // Verhoog gevonden-items-teller.
                    
}
                    print 
"</font>";
                }
            }
        }
        
// Automatically to URL with only one result.
        
        /*if ($this->OutputCounter == 1)
        {
            print"<script language=\"javascript\">\n";
            print"top.location.href = \"".$this->ColumnArray[0][3].$send_id."\";\n";
            print"</script>\n";
        }*/
    
}

    function 
AddColumn($Table,$ColumnToAdd,$ID_Column,$JumpToPage,$ExtraShowColumn "",$SQLExpansion "")
    {
        
array_push($this->ColumnArray,array($Table,$ColumnToAdd,$ID_Column,$JumpToPage,$ExtraShowColumn,$SQLExpansion));
    }
}


?>