[TYPO3-english] can anyone help me to check this php code?

typo3 study typostudy at gmail.com
Wed May 16 04:07:49 CEST 2012


Thanks. I tried.
But the thing is: When get the "keyword", it never be an array, so
is_array($this->piVars['keyword']) always returns false.



On Mon, May 14, 2012 at 11:01 PM, Stephen Bungert
<stephenbungert at yahoo.de>wrote:

> 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
>   );
>   }
>  }
> }
>
>
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
>


More information about the TYPO3-english mailing list