CollectionFind::limit

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

CollectionFind::limitLimit number of returned documents

Beschreibung

public mysql_xdevapi\CollectionFind::limit(int $rows): mysql_xdevapi\CollectionFind

Set the maximum number of documents to return.

Parameter-Liste

rows

Maximum number of documents.

Rückgabewerte

A CollectionFind object that can be used for additional processing; chain with the execute() method to return a DocResult object.

Beispiele

Beispiel #1 mysql_xdevapi\CollectionFind::limit() 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");
$create $schema->createCollection("people");
$create
  
->add('{"name": "Alfred", "age": 18, "job": "Butler"}')
  ->
execute();
$create
  
->add('{"name": "Reginald", "age": 42, "job": "Butler"}')
  ->
execute();


// ...

$collection $schema->getCollection("people");

$result $collection
  
->find('job like :job and age > :age')
  ->
bind(['job' => 'Butler''age' => 16])
  ->
sort('age desc')
  ->
limit(1)
  ->
execute();

var_dump($result->fetchAll());
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

array(1) {
  [0]=>
  array(4) {
    ["_id"]=>
    string(28) "00005b6b536100000000000000f3"
    ["age"]=>
    int(42)
    ["job"]=>
    string(6) "Butler"
    ["name"]=>
    string(8) "Reginald"
  }
}

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

Safe Diablo 4 Item Deals on U4GM: What You Need to Know

Progressing through Diablo 4 often requires more than just skill. Building a powerful character means collecting high-quality equipment, valuable ...

Geschrieben von Jimekalmiya am 01.07.2026 01:59:45
Forum: Bücher-Forum
+27734009912 medium sorcerer prof jomo denis in new york city, usa

Prof Jomo Denis is a practicing medium who works all over the world. He helps in the most difficult situations, quickly and effectively. His influ ...

Geschrieben von profjomo am 01.07.2026 00:38:49
Forum: Off-Topic Diskussionen
Genie invocations and summons in Accra Ghana+27734009912

Jinn’s, Genies are also living beings but they are made of fire. Genie or Jinn’s can be conquered by human beings by special invocations and i ...

Geschrieben von profjomo am 01.07.2026 00:36:36
Forum: Off-Topic Diskussionen
+27734009912 Spell to punish an evil person in Kingston Jamaica

There is nothing worse than knowing someone is out to harm you or destroy you. Even if they are not outwardly threatening you with physical harm, ...

Geschrieben von profjomo am 01.07.2026 00:34:37
Forum: Off-Topic Diskussionen