Uploaded image for project: 'Couchbase PHP client library'
  1. Couchbase PHP client library
  2. PCBC-937

removeMulti does not remove documents.

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • Major
    • 4.1.5
    • None
    • None
    • None
    • 0

    Description

      % cat t2.php
      <?php

      // NOTE: Change the below vendor path to your own.
      // require_once '../../../vendor/autoload.php';
      require_once '/usr/local/share/pear/Couchbase/autoload.php';

      use Couchbase\ClusterOptions;
      use Couchbase\Cluster;
      use Couchbase\TransactionOptions;
      use Couchbase\TransactionAttemptContext;

      $clusterOptions = new ClusterOptions();
      $clusterOptions->credentials('Administrator', 'password');
      $cluster = new Cluster('couchbase://localhost', $clusterOptions);

      $bucket = $cluster->bucket('my_bucket');
      $scope = $bucket->defaultScope();
      $collection = $scope->collection('_default');

      $collection->upsert('111','{}');
      $collection->upsert('222','{}');

      echo PHP_EOL;
      echo $collection->exists('111')->exists() ? '111 is Exists' : '';
      echo PHP_EOL;
      echo $collection->exists('222')->exists() ? '222 is Exists' : '';
      echo PHP_EOL;

      echo 'Remove 111 and 222';
      echo PHP_EOL;
      $result = $collection->removeMulti([
      '111',
      '222',
      ]);

      print_r ( $result ) ;

      echo $collection->exists('111')->exists() ? '111 is Exists' : '111 removed';
      echo PHP_EOL;
      echo $collection->exists('222')->exists() ? '222 is Exists' : '222 removed';
      echo PHP_EOL;

      ?>
      michaelreiche@HQML0612s-MBP Couchbase % php -e t2.php
      PHP Warning: Module "couchbase" is already loaded in Unknown on line 0

      Warning: Module "couchbase" is already loaded in Unknown on line 0
      PHP Warning: Module "couchbase" is already loaded in Unknown on line 0

      Warning: Module "couchbase" is already loaded in Unknown on line 0

      111 is Exists
      222 is Exists
      Remove 111 and 222
      Array
      (
      [0] => Couchbase\MutationResult Object
      (
      [id:Couchbase\Result:private] => 111
      [cas:Couchbase\Result:private] => 176635d87e5e0000
      [error:Couchbase\Result:private] =>
      [mutationToken:Couchbase\MutationResult:private] =>
      )

      [1] => Couchbase\MutationResult Object
      (
      [id:Couchbase\Result:private] => 222
      [cas:Couchbase\Result:private] => 176635d87e6c0000
      [error:Couchbase\Result:private] =>
      [mutationToken:Couchbase\MutationResult:private] =>
      )

      )
      111 is Exists
      222 is Exists
      michaelreiche@HQML0612s-MBP Couchbase %

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            avsej Sergey Avseyev
            michael.reiche Michael Reiche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty