Mandango is a simple, powerful and ultrafast Object Document Mapper (ODM) for PHP and MongoDB.
See the documentation in http://mandango.org/doc/
Mandango is a simple, poweful and ultrafast Object Document Mapper (ODM) for PHP and MongoDB.
License: MIT License
Mandango is a simple, powerful and ultrafast Object Document Mapper (ODM) for PHP and MongoDB.
See the documentation in http://mandango.org/doc/
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for mandango/mandango 1.0.*@dev -> satisfiable by mandango/mandango[1.0.x-dev].
- mandango/mandango 1.0.x-dev requires mandango/mondator 1.0.*@dev -> no matching package found.
Guys,
can I ask you for help, cause I was always updating mandango to the latest version just downloading zip and uploading into server, now I think it need more components to make it work, so is there easy way to install it on the server with all modules (mondator, vendors etc)?
thanx
chris
it could be great to have method like "addDocument" instead of "addDocuments"
[ErrorException]
Runtime Notice: Declaration of Mandango\Logger\LoggableMongoCollection::batchInsert() should be compatible with that of MongoCollection::batchInsert() in /vagrant/vendor/mandango/src/Mandango/Logger/LoggableMongoCollection.php line 340
When we call $articles = $articleRepository->createQuery()->references('author')->all();
it give error
it should be $articles = $articleRepository->createQuery()->references(array('author'))->all();
parameter should be array in refrences
Relations are loaded individually
The is no relations method on queries like there is for references
This means relations are not fetched with a single query
If you are happy with this functionality being added to core I will go ahead and do it
I already have a proof of concept for many to one relations in a specific query class
just needs tests and twig implementation
HI,
for example i see http://mandango.org/doc/mandango/grid-fs.html
my object is :
array(
'CommonsFile' => array(
'isFile' => true,
'collection' => 'Commons_File',
'fields' => array(
'name' => 'string',
),
),
);
php code:
$file = $mandango->create('CommonsFile');
$file->setFile("/usr/local/data/sample/pdf2.pdf");
$file->setName("New File");
$file->save();
log:
[error] [client 192.168.0.200] PHP Fatal error: Call to undefined
method CommonsFile::setFile()
tnx
it could be great to rename template.php to template.php.twig in order to have ide color and completion ;)
i can submit a PR if you agree
I'm getting some warnings and strange behaviour when removing embeddeds from a document with Mandango. I'm using the latest commit as of this date (d836103). I couldn't see any tagged versions to back test?
The code I'm using for testing is available here: https://github.com/rb-cohen/mandango_embed_test
Essentially, I create a document with an embeddedsMany field and assign two embeddeds to it. On deleting one of the embeddeds, and then reloading the document the following notice appears multiple times:
PHP Warning: Cannot use a scalar value as an array in src/Model/Base/ArticleQuery.php on line 30
PHP Stack trace:
PHP 1. {main}() testQuery.php:0
I also end up with a blank document:
array(2) {
'name' =>
NULL
'text' =>
NULL
}
I just wanted to check I'm doing this right, I've had a quick look through the Mandango repository code and can't see what would cause this at first glance:
$comments = $article->getComments()->all();
$comment = array_shift($comments);
$article->removeComments($comment);
$article->save();
When we define a default behavior we might override it in the model definition to specify some option. Right now it does create the same behavior twice.
2 Options:
Is this project active / inactive? We've been using / contributing to ODM for about 8 months now and are interested in exploring other options. I see that the last commit was 3 months ago.. Is it just b/c it's super awesome and stable, or no one is maintaining it! :P... If it's awesome and stable, I'd love to have some team members start using and contributing as well.
When we run a fairly large test suite - the number of connections to mongo seems to keep on increasing until it maxes out and our tests start failing. Is there perhaps a way of resetting the connections on tearDown? Or it not to happen in the first place?
@pablodip - I think @johnwards asked you about it and you said it was purposeful, could you explain if so?
I'm have configuration from Documentation step by step.
And I have this structure to generate with Mondator.
But when i'm tying to save documents I have NO errors
BUT nothing saves to DB. No error and no data in DB.
MongoDB runs on standard port and I tested it.
Why I have no errors and nothing saved in database?
Clicking the link http://mandango.org/doc/
on ReadMe redirects to gift scam sites that asks credit card information on Chrome, and gambling sites on Firefox.
I also reported to Github support.
Using ->resetGroups()
on an EmbedsMany document doesn't seem to work for me when I've brought an object in from mongo. (prior to saving - it does remove the documents)
This also seems to be the case with ->remove[Embedded](โฆ)
.
Would these rely on the object having an _id
?
Can we create a Document without mentioning any fields or something that indicated that it will have "n" numbers of fields.
sudo pecl install mongo
downloading mongo-1.6.4.tgz
But Travis build only for php 5.4 and MONGO_VERSION=1.3.6
Then apply my pull with replace Mongo class to MongoClient.
Would you check this, please?
effective on embeddedsMany...
Core.php:2500
// updates
foreach ($updates as $document) {
if ($document->isModified()) {
$preUpdate$query = $document->queryForSave();
$collection->update(array('_id' => $document->getId()), $query, $updateOptions);
if (isset($query['$unset'])) {
$pullQuery = array('$pull' => array());
foreach ($query['$unset'] as $key => $value) {
$pullQuery['$pull'][substr($key, 0, strrpos($key, '.'))] = null;
}
$collection->update(array('_id' => $document->getId()), $pullQuery);
}
$document->clearModified();$resetGroupsCode$postUpdate
}
}
I only read data in document but sometime mandango has error "Cannot use a scalar value as an array", can anyone help me?
I have a requirement where i am migrating the mysql db structure to mongodb.
i have the configuration array ready but the number of entries are greater than 100. approx 130.
The system gives a PHP error and classes are not generated. in case i do it by iteration, only the last entry of the config array gets processed and even though the classes are formed for all, the documents are not saved, giving out issues.
Please fix so that either we add document structures via iteration or in one go it self takes the complete bulk.
I'm working on some DBRef enhancements for mandango and I have run into undefined behaviour regarding polymorphic fields. When using such references it's possible to have duplicate IDs in references:
$id = new MongoId();
$o1 = $repository->create('C1')->setId($id); // collection1
$o2 = $repository->create('C2')->setId($id); // collection2
$o3->setPolimorphic(array($o1, $o2));
This will work and will also work with updates and deletes but seems like a side effect of rather then intended behaviour (it's not covered by any test) and eventually will fail on corner cases (c1,c2 being in the same collection for once).
Should I consider supporting duplicates if I'd like to merge my patches in the future or is it something that can freely be removed (removal also allows for some optimizations in code but this is a minor issue).
My take on this is: toss it. It's weird to have non-unique IDs and edge cases are way to hard to support.
When connecting to Bluemix Mongo DB over SSL with
$connection->setOptions(["ssl" => true,]);
I get MongoConnectionException (13053) No suitable servers found (`serverSelectionTryOnce` set): [TLS handshake failed: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed calling ismaster
.
I believe I need to specify sslAllowInvalidCertificates
or alternatively verify_peer
options as documented in Connecting over SSL.
CLI command using mongo --ssl --sslAllowInvalidCertificates
works without any problems.
How to specify that SSL should be used but in a less strict more? Thanks.
Hey there,
there is a little issue on the mandango-homepage. If you go to http://mandango.org and click on Documentation the link is ok.
If you are on http://mandango.org/doc/ the link "Documentation" in the top-nav-bar points to http://mandango.org/documentation/ instead of http://mandango.org/doc/.
A little fix would be nice :)
Removing a non existing referenced document, removes any arbitary document from the referenced documents list!
Here is an example:
Model\Dao\Author:
fields:
Name: string
referencesMany:
Articles:
class: Model\Dao\Article
Model\Dao\Article:
fields:
Title: string
Now in the PHP code:
$author= new \Model\Dao\Author();
$author->setName('Pablo');
$author->save();
$article1 = new \Model\Dao\Article();
$article1->setTitle('The first article written by Pablo');
$article1->save();
$author->addArticles($article1);
$article2 = new \Model\Dao\Article();
$article2->setTitle('The second article written by Pablo');
$article2->save();
$author->addArticles($article2);
$article3 = new \Model\Dao\Article();
$article3->setTitle('The third article written by Pablo');
$article3->save();
$author->addArticles($article3);
$article4 = new \Model\Dao\Article();
$article4->setTitle('The Fourth article which is not written by Pablo');
$article4->save();
$author->save();
//So far so good.. the three articles are linked to pablo
$author->removeAuthors($article4);
$author->save();
//Now we have lost an article when we shouldn't (probably the first article)
$articles = $author->getArticles();
var_dump(count($articles)); // 2 instead of 3
foreach($articles as $a)
{
var_dump($a->getTitle());
}
If $article4 bellonged to pablo, it would have been removed correctlly. However when it doesn't, Mandango removes just any article.. most likely the first one.
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Identifier "mandango.configuration" is not defined
i can't use the mandango extension i have always this error , i dont know where is the problem
i want to use mandango in silex
the cache is maybe not reliable, I've made some test with ab command (apache bench) with maybe concurent level set to 10 or more and sometimes, the resulting cache make the application crash... with an error about scalar variable. In order to solve it I have to empty the cache folder...
Maybe it would be more reliable to use zend cache... ?
An embedded document refering to another document using referencesMany does not work. It ignores saving the reference ids.
Here is an example:
Model\Dao\User:
fields:
Name: string
embeddedsMany:
Categories:
class: Model\Dao\Category
Model\Dao\Category:
isEmbedded: true
referencesMany:
Relationships:
class: Model\Dao\Relationship
fields:
Name: string
Model\Dao\Relationship:
fields:
Name: string
Now in the PHP code:
$u1 = new \Model\Dao\User();
$u1->setName("user1");
$u1->save();
$rel = new \Model\Dao\Relationship();
$rel->setName("rel");
$rel->save();
$cat = new \Model\Dao\Category();
$cat->setName("Cat1");
$cat->addRelationships($rel);
$u1->addCategories($cat);
$u1->save();
Mandango totally ignores the reference in the embedded document "Category".
We have a replica set however when we query to update a model the update does not go through. The code is
$TCPModel_AthleticTeamRepository = new TCPModel_AthleticTeamRepository();
$TCPModel_AthleticTeam = $TCPModel_AthleticTeamRepository->createQuery(
array(
'campus_id' => intval($AthleticsFeedObj->get_feed_entity()->get_campus_id()),
'api_version_id' => intval($AthleticsFeedObj->get_api_version_id()),
'team_id' => intval($AthleticsFeedObj->get_athletics_feed_id())))
->slaveOkay(true)
->one();
if(!$TCPModel_AthleticTeam)
{
$TCPModel_AthleticTeam = new TCPModel_AthleticTeam();
}
$TCPModel_AthleticTeam->setCode($AthleticsFeedObj->get_athletics_feed_id());
$TCPModel_AthleticTeam->save();
Saving a new one works every time but updating does not.
Hi,
When I call save() after calling setDocumentData() (even with the "true" second parameter, although the cleaning seems to be forced in the generated code : "true || $bClean"), it has no effect and the values are not saved. However, $doc->toArray(true) gives me the updated values. But they are not stored in the database.
In order to properly store the values, I have to manually call each (needed) setter before calling save().
// Does not work
$oDoc->setDocumentData($aPostData);
$oDoc->save();
// Does work
$oDoc->setField1($mValue1);
$oDoc->save();
Thank you,
To allow better extension and unit testing any document creation should use the create method of Mandango instead of a direct new.
Exemple:
$embedded = new {{ embedded_one.class }}($this->getMandango());
Should be replace by
$embedded = $this->getMandango()->create({{ embedded_one.class }});
If the model has fields with default values then the method ::setDocumentData() in the base class is always clear the default values.
public function initializeDefaults()
{
$this->setCount(0);
}
.....
public function setDocumentData($data, $clean = false)
{
if (true || $clean) { // <---- !?
$this->data = array();
$this->fieldsModified = array();
}
private function documentSetDocumentDataMethodProcess() // 632 row
{
.....
$forzeClean = false; // Maybe here should specify TRUE ?
.....
if (isset($field['default'])) {
$forzeClean = true; // And here should specify FALSE ?
}
}
$fieldsCode = implode("\n", $fieldsCode);
$forzeClean = $forzeClean ? 'true || ' : '';
.....
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.