I have the task to $unset
some fields from a collection, what i am trying to do :
$collection->update(
array(
'field' => array('$exists' => true),
),
array(
'$unset' => array(
'field' => '',
)
),
array(
'multi' => true
)
);
In xdebug i am getting: $collection: {w => 1, wtimeout => 10000}
but when i check database nothing was changed my field is there untouched.
Found the issue: Actually the parameter for multi
in php is multiple
, i didn't count the responses and didn't see that it was unset-ing just one document.
$collection->update(
array(
'field' => array('$exists' => true),
),
array(
'$unset' => array(
'field' => '',
)
),
array(
'multiple' => true
)
);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加