Code Monkey home page Code Monkey logo

Comments (13)

bjori avatar bjori commented on August 14, 2024

Can you paste your example code?

It looks like you might be doing $collection->insertOne($document, $options); where $options["writeConcern"] is not an instance of MongoDB\Driver\WriteConcern

from mongo-php-driver.

sc0rp10 avatar sc0rp10 commented on August 14, 2024

oh, sorry.

/** @var MongoDB\Collection $collection */
$collection->insertOne([
    'foo' => 'bar',
]);

from mongo-php-driver.

sc0rp10 avatar sc0rp10 commented on August 14, 2024

I've created MongoDB\Collection with $writeConcern = null.
Below I see $this->writeConcern = $writeConcern ?: $this->manager->getWriteConcern();
var_dump($this->manager->getWriteConcern()) in vendor/mongodb/mongodb/src/Collection.php:69 shows

array(4) { ["wmajority"]=> bool(false) ["wtimeout"]=> int(0) ["fsync"]=> NULL ["journal"]=> NULL }

from mongo-php-driver.

sc0rp10 avatar sc0rp10 commented on August 14, 2024

My mongodb.so was built from PHP7 branch of this repo, because I'm using php7

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

The var_dump will call the debug handler on the object, which is why you see it as array.
If you do

$wc = $this->manager->getWriteConcern();
var_dump(get_class($wc), $wc);

it should print out MongoDB\Driver\WriteConcern

from mongo-php-driver.

sc0rp10 avatar sc0rp10 commented on August 14, 2024

I got 'Warning: get_class() expects parameter 1 to be object, array given'

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

heh. uhm.. OK.... thats weird!

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

Can you try this for me:

$ php -r '$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");  $wc = $manager->getWriteConcern(); var_dump($wc);'

I get the following:

object(MongoDB\Driver\WriteConcern)#2 (4) {
  ["w"]=>
  NULL
  ["wmajority"]=>
  bool(false)
  ["wtimeout"]=>
  int(0)
  ["journal"]=>
  NULL
}

from mongo-php-driver.

sc0rp10 avatar sc0rp10 commented on August 14, 2024
 php -v && php -r '$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");  $wc = $manager->getWriteConcern(); var_dump($wc);'
PHP 7.0.0 (cli) (built: Dec  5 2015 00:06:25) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.4.0RC2, Copyright (c) 2002-2015, by Derick Rethans
array(4) {
  ["wmajority"]=>
  bool(false)
  ["wtimeout"]=>
  int(0)
  ["fsync"]=>
  NULL
  ["journal"]=>
  NULL
}

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

Ahhh. Found it.
You are using the PHP7 branch. It is no longer the most-up-2-date. @jmikola has a PR that is the latest version -- not entirely sure why its not merged into the branch or the branch deleted..

Using his PR it works for me (tm).

See: #136

from mongo-php-driver.

sc0rp10 avatar sc0rp10 commented on August 14, 2024

I've said it earlier: #153 (comment) :-)
Ok, thx, I'll be watch for progress.

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

Yeah, sorry. I mistakenly read it as if you were using @jmikola PHP7 branch, as thats what I was using hehe. Sorry :)

from mongo-php-driver.

jmikola avatar jmikola commented on August 14, 2024

#175 (PHP 7 support) has been merged to master, so I think this can be closed. We should have a release with those changes out in a day or two. Feel free to re-open if that's not the case.

from mongo-php-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.