* @method Users setGroups()设置当前记录的“Groups”集合

时间:2011-09-19 21:00:18

标签: php symfony1 doctrine symfony-1.4

我想在一个用户的所有字段中设置null。 如果这是简单的字段,例如:

* @method Users             setNumber()                 Sets the current record's "number" value

然后我做:

$user = $query;
$user->setNumber(NULL);
$user->save();

这个工作正常,但我想为此添加

* @method Users            setGroups()            Sets the current record's "Groups" collection

但如果我做:

$user = $query;
$user->setNumer(NULL);
$user->setUsers(NULL);
$user->save();

我有错误:

Couldn't call Doctrine_Core::set(), second argument should be an instance of Doctrine_Collection when setting many-to-many references.

第二个论点必须如何?

1 个答案:

答案 0 :(得分:0)

$user['Groups'] = new Doctrine_Collection('Group');

即。您将值设为空集合的组对象