Zamieszcze bezpośrednio ;]
<?php
class Vframe_Util_Search
{
protected
$_aFields = array();
public function __construct
(array $aFields) {
$this->_aFields = $aFields;
}
public function LookUp($sString)
{
// get all pharses with can't be found
// pharses with should be found
// escape pharses from string and get all words
foreach($aPharsesLike[1] as $sPharse)
$aItems[] = $sPharse;
foreach($aPharsesDebar[1] as $sPharse)
$aItems[] = '-' . $sPharse;
foreach($aItems as $sItem)
if(($sItem = trim($sItem))) {
$bLike = true;
// minus character means it can't be found
{
$bLike = false;
}
foreach($this->_aFields as $sField)
{
$sElement = '`' . $sField . '` ' . ((!$bLike) ? 'NOT ' : '') . 'LIKE "%' . $sItem . '%"';
if($bLike)
$aQueryAdd[] = $sElement;
else
$aQueryNot[] = $sElement;
}
}
$aQuery[] = implode(' OR ', $aQueryAdd);
$aQuery[] = implode(' AND ', $aQueryNot);
}
}
$oSearch = new Vframe_Util_Search
(array('news_title', 'news_content')); echo $oSearch->LookUp('wystap słowo "wystap fraza" -"ale nie ta" -nieto');
?>