PHP code example of 99designs / moa

1. Go to this page and download the library: Download 99designs/moa library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

99designs / moa example snippets




$connection = new Mongo(); // or whatever
Moa::setup($connection->mydatabase);



Moa::setup(function() {
    $connection = new Mongo();
    return $connection->someDb; 
});



$connection = new Mongo(); // or whatever
Moa::setup($connection->mydatabase);
Moa::instance()->addDatabase('anotherDb', $connection->differentDb); // also takes a callback



class TestDocument extends Moa\DomainObject
{
    public function properties()
    {
        return array(
            'myInt' => new Moa\Types\IntegerField(array('(array('type'=>'TestDocument')),
        );
    }
}



$docs = TestDocument::find(array('myString'=>'value'));

// it is also possible to use cursor methods
$docs = TestDocument::find(array('myString'=>'value'))->skip(20)->limit(10);

// findOne also works
$doc = TestDocument::findOne(array('myString'=>'value')); // this could except

// Documents may be saved via a call to save()
$doc->myInt = 123;
$doc->save();

// Documents can be deleted
TestDocument::remove(array('myString' => 'value')); // Deletes all documents with a field 'myString' with value of 'value'