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"锟斤拷 锟斤拷锟节o拷锟斤拷锟斤拷使锟斤拷 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 锟斤拷支锟街o拷之前只锟斤拷锟斤拷 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--;
}

?>

锟轿硷拷