Code Monkey home page Code Monkey logo

mandango's Introduction

Mandango

Build Status

Mandango is a simple, powerful and ultrafast Object Document Mapper (ODM) for PHP and MongoDB.

Documentation

See the documentation in http://mandango.org/doc/

mandango's People

Contributors

anasser avatar antonstoeckl avatar brikou avatar dripolles avatar jfbus avatar johnwards avatar mcuadros avatar pablodip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mandango's Issues

Composer installation fails

 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.

installation of latest version

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

Mandango not compatible with PHP Mongo driver >= 1.2.7

[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

Error in documentation for refrence

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

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

GridFS Problem

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

Removing embeddeds

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();

Active, or inactive?.... That is the question!

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.

Increasing number of connections on long lived scripts

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?

Why I have no errors and nothing saved in database?

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?

resetGroups/remove on persisted EmbedsMany documents

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?

Add compability up to latest mongo ext

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.

I want use combination $unset/$pull instead of $unset

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
}
}

Mandator fails to process documents when config classes are greater than 100

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.

Is ID non-uniqness support a bug or a feature (polimorphic fields)

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.

Connecting over SSL error. Specify context? sslAllowInvalidCertificates

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.

Removing non existing referenced document, removes any arbitary document!

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.

Mandango issue with composer?

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

cache processing is self overwriting (and crash...)

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 cannot refer to other documents

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".

When querying from a replica set, cannot always update object

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.

save() has no effect when using setDocumentData()

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,

Change generated code to user $this->getMandango()->create({{class}});

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 }});

Method ::setDocumentData() is always clear the default values

If the model has fields with default values then the method ::setDocumentData() in the base class is always clear the default values.

Base model class code:

public function initializeDefaults()
{
    $this->setCount(0);
}
.....
public function setDocumentData($data, $clean = false)
{
    if (true || $clean) {  // <---- !?
        $this->data = array();
        $this->fieldsModified = array();
    }

Mandango/Extension/Core.php:

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 || ' : '';
.....

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.