Doctrine mongodb - Symftony/Xpression GitHub Wiki
Doctrine Mongodb Expression
/!\ Mongodb Expression doesn't support not or xor
These not supported operator was not allowed to use and the parser will throw UnsupportedTokenTypeException
use Doctrine\Common\EventManager;
use Doctrine\MongoDB\Connection;
use Doctrine\MongoDB\Database;
use Symftony\Xpression\QueryStringParser;
use Symftony\Xpression\Bridge\Doctrine\MongoDb\ExprBuilder;
use Symftony\Xpression\Parser;
QueryStringParser::correctServerQueryString();
$parser = new Parser(new ExprBuilder());
$expression = $parser->parse($_GET['query']);
$connection = new Connection('mongo://localhost/');
$database = new Database($connection, $connection->myDatabase, new EventManager());
$collection = $database->selectCollection('myCollection');
$results = $collection
->createQueryBuilder()
->setQueryArray($expression->getQuery())
->getQuery()
->execute();