Last active
January 5, 2018 17:21
-
-
Save ThomasSquall/82b4ae7a09c2cdf4d61e19a6e22405ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once "vendor/autoload.php"; | |
include_once "src/Adapter.php"; | |
include_once "src/Configs.php"; | |
use MongoDriver\Adapter; | |
use MongoDriver\Configs; | |
/** | |
* [\MongoDriver\Models\Model(name = "cars")] | |
*/ | |
class Car | |
{ | |
/** | |
* [\MongoDriver\Models\Fields\Required] | |
* @var string $name | |
*/ | |
public $name; | |
/** | |
* [\MongoDriver\Models\Fields\Ref(model = "Owner", field = "name")] | |
* @var string $owner | |
*/ | |
public $owner; | |
} | |
/** | |
* [\MongoDriver\Models\Model(name = "owners")] | |
*/ | |
class Owner | |
{ | |
/** | |
* [\MongoDriver\Models\Fields\Required] | |
* @var string $name | |
*/ | |
public $name; | |
} | |
Configs::registerModel("testDB", new Car()); | |
Configs::registerModel("testDB", new Owner()); | |
$adapter = new Adapter(); | |
$adapter->connect("mongodb://localhost:27017"); | |
$adapter->selectDB("testDB"); | |
$find = $adapter->findOne("cars")->populate('owner'); | |
print_r($find); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment