MongoCollection::remove

(PECL mongo >=0.9.0)

MongoCollection::remove�Ӽ�����ɾ����¼

˵��

public MongoCollection::remove ([ array $criteria = array() [, array $options = array() ]] ) : bool|array

����

criteria

��ɾ����¼��������

options

ɾ����ѡ�

  • "w"

    See WriteConcerns. The default value for MongoClient is 1.

  • "justOne"

    ���ֻɾ��һ��ƥ��ļ�¼��

  • "fsync"

    Boolean, defaults to FALSE. Forces the insert to be synced to disk before returning success. If TRUE, an acknowledged insert is implied and will override setting w to 0.

  • "j"

    Boolean, defaults to FALSE. Forces the write operation to block until it is synced to the journal on disk. If TRUE, an acknowledged write is implied and this option will override setting "w" to 0.

    Note: If this option is used and journaling is disabled, MongoDB 2.6+ will raise an error and the write will fail; older server versions will simply ignore the option.

  • "w"

    See WriteConcerns. The default value for MongoClient is 1.

  • "wtimeout"

    Deprecated alias for "wTimeoutMS".

  • "safe"

    Deprecated. Please use the WriteConcern w option.

  • "timeout"

    Integer, defaults to MongoCursor::$timeout. If "safe" is set, this sets how long (in milliseconds) for the client to wait for a database response. If the database does not respond within the timeout period, a MongoCursorTimeoutException will be thrown.

����ֵ

��������� "w" ѡ����᷵�ذ���ɾ��״̬�� array�� ���򷵻� TRUE��

״̬�����ֶεĽ���λ�� MongoCollection::insert() ���ĵ���

�����쳣

Throws MongoCursorException if the "w" option is set and the write fails.

Throws MongoCursorTimeoutException if the "w" option is set to a value greater than one and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. The operation in MongoCollection::$wtimeout is milliseconds.

������־

�汾 ˵��
1.3.0 options �������ٽ��� boolean ֵ������ "justOne"�� ���ڣ�����ʹ�� array('justOne' => true) ��Ϊ�����
1.2.11 �� options �� scalar ʱ����һ�� E_DEPRECATED ���档
1.2.0 ��� "timeout" ѡ�
1.0.11 �������� "safe" ֮�󣬽��ڳ��� "not master" ����ʱ�Ͽ����ӡ�
1.0.9

����� "safe" ѡ��� integer ��֧�֣�֮ǰֻ���� boolean ֵ��

����� "fsync" ѡ�

��ʹ���� "safe" ѡ��ʱ���᷵�ذ���������Ϣ�����顣 �����֮ǰһ������һ�� boolean��

1.0.5 �޸ĵڶ�������Ϊѡ��� array���� 1.0.5 ֮ǰ���ڶ���ѡ���� boolean ֵ�� ������ "safe" ѡ�

����

Example #1 MongoCollection::remove() �� justOne ����

<?php

$radioactive 
$db->radioactive;

// ͳ�����ж��ٸ���
$remaining $radioactive->count(array('type' => 94));

$halflife $remaining/2;

// ɾ��һ��
while ($halflife 0) {
    
$radioactive->remove(array('type' => 94), array("justOne" => true));
    
$halflife--;
}

?>

�μ�