Code Monkey home page Code Monkey logo

Comments (7)

bjori avatar bjori commented on September 15, 2024

We don't store the class reference by default. You must explicitly implement the MongoDB\BSON\Persistable interface.

It was decided that the driver should be consistent with the wire protocol format (e.g. BSON) when it came to serialization of containers -- so the "root document" should be considered as stdClass, not array. See: https://jira.mongodb.org/browse/PHPC-319

You can configure this behavior by setting the typemap yourself:

$result = $manager->executeQuery(NS, $query);
$result->setTypeMap(array("document"=> "array", "root" => "array"));
foreach($result as $document) {
    var_dump($document);
}

from mongo-php-driver.

derickr avatar derickr commented on September 15, 2024

@thawkins Does @bjori's comment address your concern?

from mongo-php-driver.

thawkins avatar thawkins commented on September 15, 2024

Not 100%, i still think there is a need where we can set

$result->setTypeMap(array("document"=> "array", "root" => "array"));

As the default behaviour, otherwise it just adds a load of noise to the interface if people are forced to do this on every query for compatability reasons.

Something like

$manager->setDefaultTypeMap(array("document"=> "array", "root" => "array"));

Im going to have to try converting our ORM to work with the new driver so i have to hide all this in our MongoCollection analog class. Our ORM is very like doctrine, but has a bunch of support for automatic DublinCore Metadata in each object.

It already does its own class factory, so the one in tbe driver just gets in the way.

from mongo-php-driver.

derickr avatar derickr commented on September 15, 2024

Hi @thawkins,

The driver itself is meant to be as bare bones as possible, and hence setting a default type map is not in the scope of the driver.

However, we are going to address this in the accompanying library. There is an issue at mongodb/mongo-php-library#39, and a ticket too: https://jira.mongodb.org/browse/PHPLIB-74

cheers,
Derick

from mongo-php-driver.

jmikola avatar jmikola commented on September 15, 2024

@thawkins: Would you mind taking a look at mongodb/mongo-php-library#73? I believe this implements what you were requesting.

from mongo-php-driver.

thawkins avatar thawkins commented on September 15, 2024

We are starting to look at the migration in mid jan, at the moment we are stabilising a large deployment on php5.6/3.0.8/legacy driver. Once that is complete and deployed, i can free up some of my developers to start working through the migration issues. We will be targeting php7/3.2.1/new driver/phplib.

from mongo-php-driver.

jmikola avatar jmikola commented on September 15, 2024

@thawkins: Thanks for following up. I'm going to close this out, as the corresponding PHPLIB ticket should address your needs. Feel free to ping us later on if you have additional concerns/feedback, though.

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.