Collection::modify

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

Collection::modifyModify collection documents

Beschreibung

public mysql_xdevapi\Collection::modify(string $search_condition): mysql_xdevapi\CollectionModify

Modify collections that meet specific search conditions. Multiple operations are allowed, and parameter binding is supported.

Parameter-Liste

search_condition

Must be a valid SQL expression used to match the documents to modify. This expression might be as simple as true, which matches all documents, or it might use functions and operators such as 'CAST(_id AS SIGNED) >= 10', 'age MOD 2 = 0 OR age MOD 3 = 0', or '_id IN ["2","5","7","10"]'.

Rückgabewerte

If the operation is not executed, then the function will return a Modify object that can be used to add additional modify operations.

If the modify operation is executed, then the returned object will contain the result of the operation.

Beispiele

Beispiel #1 mysql_xdevapi\Collection::modify() 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");

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

// Add two new jobs for all Painters: Artist and Crafter
$collection
  
->modify("job in ('Butler', 'Painter')")
  ->
arrayAppend('job''Artist')
  ->
arrayAppend('job''Crafter')
  ->
execute();

// Remove the 'beer' field from all documents with the age 21
$collection
  
->modify('age < 21')
  ->
unset(['beer'])
  ->
execute();
?>

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

Spring Exercising Recreation Thread #4: Milwaukee Brewers

The Cactus League Brewers are again in just motion and hunting in the direction of order off the schneid this afternoon the moment wasting either ...

Geschrieben von WerryPing am 15.07.2026 11:56:03
Forum: XML
Mariners dilemma their path towards acquire in excess of Orioles, 6-3

Jun 8, 2026; Baltimore, Maryland, United states; Seattle Mariners initially baseman Josh Naylor 12 celebrates with his teammates following hitting ...

Geschrieben von WerryPing am 15.07.2026 11:55:28
Forum: SQL / Datenbanken
Nathan Eovaldi retains rolling towards Yankees as Will Warren falters

Fresh YORK, Fresh YORK May well 06: Nathan Eovaldi 17 of the Texas Rangers pitches for the duration of the 8th inning in opposition to the Fresh n ...

Geschrieben von WerryPing am 15.07.2026 11:54:47
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS
Snake Bytes 4/18: Retain the Terrific Occasions Rolling

Diamondbacks NewsSoroka and Arenado Contribute Extensive Acquire Around JaysMichael Soroka ongoing his not likely get started toward the period, a ...

Geschrieben von WerryPing am 15.07.2026 11:53:30
Forum: PHP Developer Forum