[TYPO3-english] can anyone help me to check this php code?
Stephen Bungert
stephenbungert at yahoo.de
Mon May 14 17:01:04 CEST 2012
This may work, I haven't tested it ;)
You need to split the keywords as there are more then one in your example.
function search() {
if (isset($this->piVars['keyword'])) {
if(is_array($this->piVars['keyword']) && !empty($this->piVars['keyword']))
{
$keywords = t3lib_div::trimExplode(' ', $this->piVars['keyword'], true);
if (!empty($keywords)) {
$likeClause = '';
foreach($keywords as $index => $word)
{
wordFixed = $GLOBALS['TYPO3_DB']->quoteStr($word, 'tx_jc_text');
wordFixed = $GLOBALS['TYPO3_DB']->escapeStrForLike(wordFixed,
'tx_jc_text');
if ($index > 0) {
$likeClause .= ' OR tx_jc_text.contents LIKE \'%' . wordFixed . '%\'';
} else {
$likeClause .= 'tx_jc_text.contents LIKE \'%' . wordFixed . '%\'';
}
}
}
$res = $GLOBALS['typo3_DB']->exec_SELECTquery(
'fe.uid, fe.email, fe.city',
'tx_jc_text jc LEFT JOIN fe_users fe ON fe.uid = jc.cruser_id',
$likeClause
);
}
}
}
More information about the TYPO3-english
mailing list