Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Amin Alizade  >  PHP Search Database  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Script
Class: PHP Search Database
Generate SQL to search table records for keywords
Author: By
Last change: -
Date: 9 months ago
Size: 682 bytes
 

Contents

Class file image Download
<?php

$my_search 
= new Search();
$order_column "column1";
$order_type "desc";
$offset 100;
$limit 150;

$my_search->set_table_name('my_table');
$my_search->set_terms("search term");
$my_search->set_fields(array('column1','column2','column3',));
$my_search->set_filters(array('column5'=>array('filter1','filter2')));
$my_search->set_match_case(false);

$my_search->get_query($order_column,$order_type,$offset,$limit);

/* Above line returns:

SELECT * 
FROM my_table 
WHERE (column1 LIKE '%search%term%' OR column2 LIKE '%search%term%' OR column3 LIKE '%search%term%')
AND (column5 IN ('filter1','filter2')) 
ORDER BY column1 desc 
LIMIT 100,150

*/