public function update($col, $cond, $data, $flags = 0, $cb = null, $params = [])
{
if (mb_orig_strpos($col, '.') === false) {
$col = $this->dbname . '.' . $col;
}
if (is_string($cond)) {
$cond = new \MongoCode($cond);
}
if ($flags) {
//if (!isset($data['_id'])) {$data['_id'] = new MongoId();}
}
if ($this->safeMode) {
static::safeModeEnc($cond);
static::safeModeEnc($data);
}
$this->request(self::OP_UPDATE, "" . $col . "" . pack('V', $flags) . bson_encode($cond) . bson_encode($data), false, null, function ($conn, $reqId = null) use($cb, $col, $params) {
if (!$conn) {
!$cb || $cb(['$err' => 'Connection error.']);
return;
}
if ($cb !== null) {
$this->lastError($col, $cb, $params, $conn);
}
});
}