Collection::replaceOne

(No version information available, might only be in Git)

Collection::replaceOneReplace one collection document

Beschreibung

public mysql_xdevapi\Collection::replaceOne(string $id, string $doc): mysql_xdevapi\Result

Updates (or replaces) the document identified by ID, if it exists.

Parameter-Liste

id

ID of the document to replace or update. Typically this is the _id that was generated by MySQL Server when the record was added.

doc

Collection document to update or replace the document matching the id parameter.

This document can be either a document object or a valid JSON string describing the new document.

Rückgabewerte

A Result object that can be used to query the number of affected items and the number warnings generated by the operation.

Beispiele

Beispiel #1 mysql_xdevapi\Collection::replaceOne() example

<?php
$session 
mysql_xdevapi\getSession("mysqlx://user:password@localhost");

$session->sql("DROP DATABASE IF EXISTS addressbook")->execute();
$session->sql("CREATE DATABASE addressbook")->execute();

$schema     $session->getSchema("addressbook");
$collection $schema->createCollection("people");

$result $collection->add('{"name": "Alfred", "age": 18, "job": "Butler"}')->execute();

// Normally the _id is known by other means, 
// but for this example let's fetch the generated id and use it
$ids       $result->getGeneratedIds();
$alfred_id $ids[0];

// ...

$alfred $collection->getOne($alfred_id);
$alfred['age'] = 81;
$alfred['job'] = 'Guru';

$collection->replaceOne($alfred_id$alfred);

?>

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

MMOexp ARC Raiders for uninterrupted farming sessions

Spotter Relays are valuable uncommon recyclable items in ARC Raiders BluePrints (https://www.mmoexp.com/Arc-raiders/Items.html?fsid=271041)​, wi ...

Geschrieben von BennieDe am 23.05.2026 04:32:26
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS
Rsorder OSRS of runes for combat spells

In Old School RuneScape (OSRS), efficiency is key to progressing through the game, especially when it comes to tasks that require frequent telepor ...

Geschrieben von BennieDe am 23.05.2026 04:30:37
Forum: Fragen/Vorschläge zum Forum
MMOexp Diablo4 to enhance orb duration

The Ball Lightning Sorcerer stands as one of the most versatile and dominant endgame builds in Diablo 4's latest seasons. Tailored for level 100 e ...

Geschrieben von BennieDe am 23.05.2026 04:28:51
Forum: PHP Developer Forum
Malaysia tour package

Recovering from heavy marathon training sessions was taking twice as long as it used to last year. Pushing through the constant joint aches was de ...

Geschrieben von jeromeda am 22.05.2026 22:19:40
Forum: Off-Topic Diskussionen