1
votes

I use symfony 1.4.11 with doctrine. I have helper:

function filterwords($text){

    $filterWords=array ('some','filter','words');
     $filterCount = sizeof($filterWords);
        for($i=0; $i<$filterCount; $i++){
        $text = preg_replace('/\b'.$filterWords[$i].'\b/ie',"str_repeat('*',strlen('$0'))",$text);
                                         }
        return $text;
                               }
    }

All works fine. But I want to make module, that administrator can add words to filter from backend. Is it possible to transfer data from the database to varaible $filterWords I have next schema:

Filter:
  actAs:
    Timestampable: ~
  connection: doctrine
  tableName: filter
  columns:
    word: {type: string(255), notnull: true}

I can make in helper something like this, and get word what I need :

 $record = Doctrine_Core::getTable('Filter')->getWordFilter();

 foreach ($record as $filter )

   {
 echo  $filter ->getWord();
    }

But I do not how to implement it im my function...

Sorry for my bad English.

3

3 Answers

1
votes

Just pass $filterwords in as a variable:

function filterwords($text, $filterwords)
{
   //etc.
0
votes
field = the column name that contains a value you're searching by.

$record = Doctrine_Core::getTable('Words')->findOneByField($value);
$filterWords = $record->getWord();
0
votes

I do not now is it correct, but it is work.

 function filterwords($text){
  $record = Doctrine_Core::getTable('Filter')->getWordFilter();//

   foreach ($record as $filter )
   {
        $filterWords[] =  $filter->getWord();
    }
         $filterCount = sizeof($filterWords);
        for($i=0; $i<$filterCount; $i++){
        $text = preg_replace('/\b'.$filterWords[$i].'\b/ie',"str_repeat('*',strlen('$0'))",$text);
                                         }
        return $text;
                               }