Yii findByAttributes重写函数返回错误


Yii findByAttributes overrided function returns error

我有一个Yii函数被覆盖的问题。我试图覆盖Yii中的findByAttributes函数,但它返回了以下错误:

PHP Fatal error:  Class declarations may not be nested in /var/www/html/yii14/framework/collections/CListIterator.php on line 20

我的overrided函数代码如下:

private function findByAttributes($attributes, $condition='', $params=array())
{
    foreach($attributes as $attribute=>$value)
    {
        if($attribute === 'user_email') {
            $attributes[$attribute] = md5('üyegirişyaptı'.$value);
        }
    }
    return parent::findByAttributes($attributes, $condition, $params);
}

这里怎么了?

我认为错误不在您提供的代码中。

问题:

  1. findByAttributes应该是私有的吗
  2. 你为我们准备了一个堆叠比赛吗

附带说明:我不认为你必须循环阵列

if(array_key_exists('user_email', $attributes)) 
{
   $attributes['user_email'] = md5('üyegirişyaptı'.$value);
}