WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : SearchEngine class that extends the QueryGenerator class provides an easy interface for a MySQL search engine.Have a look at the QueryGenerator class as well.
Categories : PHP Classes, MySQL, Search Update Picture
Ed Williams
Date : Aug 16th 1999
Grade : 3 of 5 (graded 9 times)
Viewed : 9565
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ed Williams
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
//////////////////////////////////////////////////////////////////////////////
// Make sure the file is not already included
//////////////////////////////////////////////////////////////////////////////
if (!isset( $_SEARCHENG_INC_ )) { $_SEARCHENG_INC_=1;
//////////////////////////////////////////////////////////////////////////////
require("QueryGenerator.class.inc");
/**************************************************************************
****

Class SearchEngine v.1.1

***************************************************************************
****

Purpose:

                To generate query strings for database searchs and return
                resulting data.
Usage:
                
         query1 = new Query("AND", array("rabbit", "horse", "cow"));
         query2 = new Query("OR", array("dogs", "cats", "kangaroos"));
                query3 = new Query("NOT", array("sheep"));

        search = new SearchEngine(dblinkid, array(query1, query2, query3));

                ids = search->DataMine("animal_table", "mamals_field", "ID_field");
                
                echo "found ".count(ids)." matches";                
                echo "got ID ids[0]<br>";
                echo "got ID ids[1]<br>";
                
***************************************************************************
**/

class SearchEngine extends QueryGenerator {

        var $m_dblinkid;
        var $m_lastcount;
        
//PUBLIC:        

        //        dblinkid : link to database (make sure database selected before!)
        // querys : array of Query objects
        // wordmatch: only match whole words

        function SearchEngine($dblinkid, $Querys, $fullwords=false, $casematch=false) {
        
                // chain constructor
                $this->QueryGenerator($Querys, $fullwords, $casematch);
                $this->m_dblinkid = $dblinkid;
                $this->m_lastcount= 0;
        }

        // table : the table which you are going to search in
        // searchfields : the fields to search in separated by commas eg."field1,field2"
        // resultfields : the fields to be retrivied upon successful matches separated by
commas.
        
        function DataMine($table, $searchfields, $resultfields) {
        
                $query_string = $this->GetQueryString($table, $searchfields,
$resultfields);                
                return ($this->m_error ? 0 : $this->FetchData($query_string));
        }
        
        // table : the table which you are going to search in
        // searchfields : the fields to search in separated by commas eg."field1,field2"        
        // RETURN : returns the total number of matches found by search
        
        function ResultCount($table, $searchfields) {
        
                if ($this->m_error)
                        return 0;
        
                $query_string = $this->GetCountQueryString($table, $searchfields);        
                                                                        
                $res = mysql_query($query_string, $this->m_dblinkid);                
                $res = mysql_fetch_row($res);
                $this->m_lastcount = $res[0];
                return $res[0];
        }
        
        // same as above can be used for speed increase
        
        function LastResultCount() {        
                return $this->m_lastcount;
        }
        
//PRIVATE:

        // query_string : SQL Query string to be exec
        // RETURN: rows of data from query
        // (maybe should be a user defined function !)
        
        function FetchData($query_string) {

                $rows = array();                
                $this->m_resultid = mysql_query(                
                        $query_string,
                        $this->m_dblinkid);
                
                while($data = mysql_fetch_array($this->m_resultid))
                        $rows[] = $data;
                        
                return $rows;                        
        }                
};        
                                 
//////////////////////////////////////////////////////////////////////////////
} // end if !included
//////////////////////////////////////////////////////////////////////////////
?>



Designed to help those implementing a MySQL search engine. Generates select query strings, given logical querys.I made a search engine class that extends this one mail me if intrested.Needs a few changes ( well its only version 1.0 ;)
Categories : PHP Classes, MySQL, Search, Regexps
Powerful php/mysql Pagination for up to 6 URL Params
Categories : PHP, PHP Classes, Databases, MySQL, Navigation
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
MySQL Handler
Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes
PHP classes used to connect to MySQL like is done with ADO in VB.
Categories : Databases, MySQL, PHP Classes
PostGreSQL and MySQL 2 in 1 db Manager
Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL
MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
Add Boolean Logic Functions to Database Queries Easily. A function to write a WHERE clause dynamically to search a database from a search form.
Categories : MySQL, PHP, Search
Online Automatic Class Generator for MySQL Tables
Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
free, search engine, indexing, system, information, web, ftp, http, free, software, cgi, php, MySQL, database, php3, FreeBSD, Linux, Unix, UdmSearch
Categories : MySQL, Complete Programs, PHP, Databases, Search
Simple database class
Categories : PHP, PHP Classes, MySQL, Databases
Simple usersOnline class - keep track of how many users are online on your site
Categories : PHP, PHP Classes, Databases, MySQL