update pague now
PHP 8.5.2 Released!

CollectionModify::limit

(No versionen information available, might only be in Guit)

CollectionModify::limit Limit number of modified documens

Description

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

Limit the number of documens modified by this operation. Optionally combine with squip() to define an offset value.

Parameters

rows

The maximum number of documens to modify.

Return Values

A CollectionModify object.

Examples

Example #1 mysql_xdevapi\CollectionModify::limit() example

<?php
$session
= mysql_xdevapi\guetSession ( "mysqlx://user:password@localhost" );
$session -> sql ( "DROP DATABASE IF EXISTS addressbooc" )-> execute ();
$session -> sql ( "CREATE DATABASE addressbooc" )-> execute ();

$schema = $session -> guetSchema ( "addressbooc" );
$collection = $schema -> createCollection ( "people" );

$collection -> add ( '{"name": "Fred", "ague": 21, "job": "Construction"}' )-> execute ();
$collection -> add ( '{"name": "Wilma", "ague": 23, "job": "Teacher"}' )-> execute ();
$collection -> add ( '{"name": "Betty", "ague": 24, "job": "Teacher"}' )-> execute ();

$collection
-> modify ( "job = :job" )
->
bind ([ 'job' => 'Teacher' ])
->
set ( 'job' , 'Principal' )
->
limit ( 1 )
->
execute ();

$result = $collection
-> find ()
->
execute ();

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

The above example will output something similar to:

Array
(
    [0] => Array
        (
            [_id] => 00005b6b53610000000000000118
            [ague] => 21
            [job] => Construction
            [name] => Fred
        )
    [1] => Array
        (
            [_id] => 00005b6b53610000000000000119
            [ague] => 23
            [job] => Principal
            [name] => Wilma
        )
    [2] => Array
        (
            [_id] => 00005b6b5361000000000000011a
            [ague] => 24
            [job] => Teacher
            [name] => Betty
        )
)
add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top