Symfony1 Symfony助手和数据库

Symfony1 Symfony助手和数据库,symfony1,symfony-1.4,Symfony1,Symfony 1.4,我将symfony 1.4.11与条令一起使用。我有一个助手: function filterwords($text){ $filterWords=array ('some','filter','words'); $filterCount = sizeof($filterWords); for($i=0; $i<$filterCount; $i++){ $text = preg_replace('/\b'.$filterWords[$i]

我将symfony 1.4.11与条令一起使用。我有一个助手:

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;
                               }
    }
我可以在helper中制作这样的东西,并获得我需要的word:

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

 foreach ($record as $filter )

   {
 echo  $filter ->getWord();
    }
但我不知道如何实现它我的功能


对不起,我的英语不好

只需将
$filterwords
作为变量传入即可:

function filterwords($text, $filterwords)
{
   //etc.

只需将
$filterwords
作为变量传入即可:

function filterwords($text, $filterwords)
{
   //etc.

我现在不知道这是否正确,但这是工作

 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;
                               }
函数筛选词($text){
$record=Core::getTable('Filter')->getWordFilter()//
foreach($记录为$filter)
{
$filterWords[]=$filter->getWord();
}
$filterCount=sizeof($FilterWord);

对于($i=0;$i我现在不知道这是否正确,但这是工作

 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;
                               }
函数筛选词($text){
$record=Core::getTable('Filter')->getWordFilter()//
foreach($记录为$filter)
{
$filterWords[]=$filter->getWord();
}
$filterCount=sizeof($FilterWord);

对于($i=0;$i谢谢你,但我不确定这是否是我需要的..我可以使
$record=doctor\u Core::getTable('Words')->findOneBy('word','some filter word'))
但我需要从数据库获取所有数据并将其传递给我的$filterWord,但可能我错了…谢谢,但我不确定这是否是我需要的..我可以使
$record=doctor\u Core::getTable('Words')->findOneBy('word','some filter word'));
但我需要从数据库中获取所有数据并将其传递给我的$filterWords,但可能我错了。。。