/** * Remove records from this collection * * @param array $criteria - Description of records to remove. * @param array $options - Options for remove. "justOne" Remove at * most one record matching this criteria. * * @return bool|array - Returns an array containing the status of the * removal if the "w" option is set. Otherwise, returns TRUE. Fields * in the status array are described in the documentation for * MongoCollection::insert(). */ public function remove(array $criteria = [], array $options = []) { $timeout = MongoCursor::$timeout; if (!empty($options['timeout'])) { $timeout = $options['timeout']; } return $this->protocol->opDelete($this->fqn, $criteria, $options, $timeout); }
private function fetchMoreDocuments() { $limit = $this->calculateNextRequestLimit(); if ($this->end) { return; } $response = $this->protocol->opGetMore($this->fcn, $limit, $this->cursorId, $this->queryTimeout); $this->setDocuments($response); }
/** * Execute a database command * * @param array $command - The query to send. * @param array $options - This parameter is an associative array of * the form array("optionname" => boolean, ...). * * @return array - Returns database response. */ public function command(array $cmd, array $options = []) { $timeout = MongoCursor::$timeout; if (!empty($options['timeout'])) { $timeout = $options['timeout']; } $response = $this->protocol->opQuery("{$this->name}.\$cmd", $cmd, 0, -1, 0, $timeout); return $response['result'][0]; }
/** * Kills a specific cursor on the server * * @param string $serverHash - The server hash that has the cursor. * This can be obtained through MongoCursor::info. * @param int|mongoint64 $id - The ID of the cursor to kill. You can * either supply an int containing the 64 bit cursor ID, or an object * of the MongoInt64 class. The latter is necessary on 32 bit platforms * (and Windows). * * @return bool - Returns TRUE if the method attempted to kill a * cursor, and FALSE if there was something wrong with the arguments * (such as a wrong server_hash). The return status does not reflect * where the cursor was actually killed as the server does not provide * that information. */ public function killCursor($serverHash, $id) { // since we currently support just single server connection, // the $serverHash arg is ignored if ($id instanceof MongoInt64) { $id = $id->value; } elseif (!is_numeric($id)) { return false; } $this->protocol->opKillCursors([(int) $id], [], MongoCursor::$timeout); return true; }