我想在一个用户的所有字段中设置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.
第二个论点必须如何?
答案 0 :(得分:0)
$user['Groups'] = new Doctrine_Collection('Group');
即。您将值设为空集合的组对象