WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : 11149
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  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
phpMyDataGrid 2007
Categories : AJAX, PHP Classes, MySQL, Databases, HTML and PHP
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
MySQL database class
Categories : PHP, MySQL, Databases, PHP Classes
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
[PHP5] aDB PDO LIKE Database Abstraction. Switch easily from one db server to another, strong errors management, manage transactions, queries preparation and more.
Categories : PHP, PHP Classes, Databases, MS SQL Server, MySQL
Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP.
Categories : PHP Classes, Databases, PHP, MySQL, InnoDB
Link Manager for Link Exchangers
Categories : PHP, PHP Classes, Databases, MySQL, CURL
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP, PHP Classes, Databases, MySQL, HTML and PHP
Simple database class
Categories : PHP, PHP Classes, MySQL, Databases
PHP Based Apache + Mysql Error Log Parser
Categories : PHP, PHP Classes, Apache, MySQL, Log Files
Convert SQL from oracle,mysql,mssql,sqlite and odbc to SQL compatible
Categories : PHP, PHP Classes, Databases, MySQL, MS SQL Server
Ajax PHP Tree (Left and Right) with MySQL
Categories : PHP, Databases, MySQL, AJAX, PHP Classes
YellowPages Content Grabber (PHP5 +)
Categories : PHP, PHP Classes, Regexps, Databases, MySQL