Comments (7)
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.
@thawkins Does @bjori's comment address your concern?
from mongo-php-driver.
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.
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.
@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.
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.
@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)
- apache stop when I added extension=mongodb.so to php.ini HOT 3
- `selectServer` takes too long on official php base image (connections opened sequentially) HOT 13
- libbson Bug Report : variable ret value type error HOT 8
- No suitable servers found (`serverSelectionTryOnce` set) when rs.initiate with localhost HOT 5
- Extract mongodb-1.6.2.tgz error HOT 5
- Sporadic "Authentication failed" errors HOT 8
- MongoDB PHP Driver 1.15+ increases PHP memory consumption HOT 7
- Error while compiling on macOS HOT 7
- Major slowdown since version 1.17.0 HOT 8
- PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' HOT 2
- MongoDB reporting "AuthenticationAbandoned: Overridden by new authentication session" for a PHP client HOT 14
- Windows build after 1.13.0 HOT 4
- linux general protection fault , sorry for my poor english HOT 1
- PHP refusing to load MongoDB PHP driver on Windows (on one machine but not another) HOT 1
- Can't download desired extension HOT 2
- Unable to install pecl mongodb-1.15.1 in php 8.2 HOT 1
- Bug & Question: How to compile mongodb statically into PHP? HOT 9
- PHPStorm Stub for Manager class has outdated signature HOT 1
- Cannot install with laravel 11 HOT 2
- Cannot run ./configure cmd - error: cannot find input file: 'config.h.in' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongo-php-driver.