Last active
August 29, 2015 14:02
-
-
Save brandonprry/c2de8ac2be825007c4de 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 | |
$m = new MongoClient("mongodb://127.0.0.1:27017"); | |
$m->selectDB('foo'); | |
$collection = $m->selectCollection('test', 'phpmanual'); | |
if ($_GET["age"] != "") { | |
$js = 'function(){if(this.name == "Joe"||this.age=='.$_GET["age"].')return true;}'; | |
$cursor = $collection->find(array('$where' => $js)); | |
foreach($cursor as $doc) { | |
var_dump($doc); | |
} | |
} elseif ($_GET["name"] != "") { | |
$js = "function(){var nom = '".$_GET["name"]."';return this.name == nom;}"; | |
$cursor = $collection->find(array('$where' => $js)); | |
foreach($cursor as $doc) { | |
var_dump($doc); | |
} | |
} elseif ($_GET["weight"] != "") { | |
$js = "function(){var w8 = \"".$_GET["weight"]."\";return this.weight == w8;}"; | |
$cursor = $collection->find(array('$where' => $js)); | |
foreach ($cursor as $doc) { | |
var_dump($doc); | |
} | |
} elseif ($_GET["sex"] != "") { | |
$js = "function(){return this.sex == \"".$_GET["sex"]."\";}"; | |
$cursor = $collection->find(array('$where' => $js)); | |
foreach ($cursor as $doc) { | |
var_dump($doc); | |
} | |
} elseif ($_GET["race"] != "") { | |
$js = "function(){return this.race == '".$_GET["race"]."';}"; | |
$cursor = $collection->find(array('$where' => $js)); | |
foreach ($cursor as $doc) { | |
var_dump($doc); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment