PHPDaemon\Clients\Mongo\Pool::remove PHP Method

remove() public method

Remove objects from collection
public remove ( string $col, array $cond = [], callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$cb callable Optional. Callback called when response received
$params array Optional. Parameters
return void
    public function remove($col, $cond = [], $cb = null, $params = [])
    {
        if (mb_orig_strpos($col, '.') === false) {
            $col = $this->dbname . '.' . $col;
        }
        if (is_string($cond)) {
            $cond = new \MongoCode($cond);
        }
        if ($this->safeMode && is_array($cond)) {
            static::safeModeEnc($cond);
        }
        try {
            $this->request(self::OP_DELETE, "" . $col . "" . "" . bson_encode($cond), false, null, function ($conn, $reqId = null) use($col, $cb, $params) {
                if (!$conn) {
                    !$cb || $cb(['$err' => 'Connection error.']);
                    return;
                }
                if ($cb !== null) {
                    $this->lastError($col, $cb, $params, $conn);
                }
            });
        } catch (\MongoException $e) {
            Daemon::log('MongoClient exception: ' . $e->getMessage() . ': ' . $e->getTraceAsString());
            if ($cb !== null) {
                $cb(['$err' => $e->getMessage(), '$query' => $cond]);
            }
        }
    }