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

rr88kacomm

rr88ka com (https://rr88ka.com/) – Nền tảng giải trí trực tuyến hiện đại, mang đến cho người dùng một không gian trả ...

Geschrieben von rr88kacomm am 18.04.2026 14:09:42
Forum: PHP Developer Forum
IGGM: WoW TBC Classic Falls Short of Player Expectations

Hy Guys, Yeah, I get why people feel that way about WoW TBC Classic. A lot of players were expecting that original immersive grind and community v ...

Geschrieben von johny83 am 18.04.2026 09:15:48
Forum: Off-Topic Diskussionen
Fehler bei Beziehung

This really requires experience and a solid understanding of source code development. Updates and knowledge sharing make learning significantly mo ...

Geschrieben von sikasema am 18.04.2026 05:59:27
Forum: PHP Developer Forum
Diablo 4 Season 12 Items Massacre Sale! Rush to D4Gold.com!

Diablo IV Season 12: Season of Slaughter is in full swing, and every player in Sanctuary is racing to stay ahead of the meta, unlock high-end gear ...

Geschrieben von salisy am 18.04.2026 04:34:44
Forum: User stellen sich vor