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

SEO-URLs und MySQL

If you spend the money you would have used on a BBW love doll (https://www.sexdollpartner.com/collections/bbw-sex-doll) to see a doctor at night, ...

Geschrieben von starsmart1512a am 24.01.2026 10:56:28
Forum: SQL / Datenbanken
variables Bild incl. Text mit PHP für eine Schleifenausgabe erstellen

Generating images dynamically in PHP with a loop becomes much cleaner once the process is treated as structured output rather than random drawing. ...

Geschrieben von jonsmith86 am 24.01.2026 07:24:48
Forum: PHP Developer Forum
Verkauf Existenz für Gründer/Agentur

Selling a business as a founder or agency usually comes down to clean numbers, clear operations, and a brand that can keep performing without the ...

Geschrieben von jonsmith86 am 24.01.2026 07:20:57
Forum: Existenzgründer, Freelancing, Verträge und sonstiges
Price calculator (Auswahlmenü) erstellen

When building a price calculator with a selection menu, it really helps to have clean, structured price data to pull from. I’ve seen people stru ...

Geschrieben von jonsmith86 am 24.01.2026 07:15:42
Forum: Off-Topic Diskussionen