Login   Register  
PHP Classes
elePHPant
Icontem

File: simple_example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alex Miles  >  Search MySQL  >  simple_example.php  >  Download  
File: simple_example.php
Role: Example script
Content type: text/plain
Description: A simple example showing the core functionality
Class: Search MySQL
Search for text in MySQL database tables
Author: By
Last change:
Date: 2012-01-14 11:08
Size: 684 bytes
 

Contents

Class file image Download
<?php

include('class.SearchMySQL.php');

define('SEARCH_TERM','needle string');

$searcher = new SearchMySQL();

if(
true) {
    
// Ignore a boring table
    
$searcher->excludeTable('boring_table');
} else {
    
// Only search these specific tables (exclusions will be ignored)
    
$searcher->includeTable('interesting_table');
    
$searcher->includeTable('really_interesting_table');
}

print_r($searcher->search(SEARCH_TERM));

unset(
$searcher);

//
// You can also pass the class your own database connection to use
//
$my_conn = new mysqli('localhost','root','','interesting_db');
$new_searcher = new SearchMySQL();
print_r($new_searcher->search(SEARCH_TERM,$my_conn));