I want to use if condition with find query I'm not able to do so can anyone suggest me. I'm using php with mongo database-
<?php
$realtime = date("2016-09-22 12:55:24");
$mongotime = New DateTime($realtime);
$mt = $mongotime->getTimeStamp();
var_dump($mt);
//database Connection
$server= mongodb://localhost:27017";
$c = new Mongo($server);
$db = $c->dbname;
echo "Database selected";
//collection selection
$collection = $db->collection;
echo "Collection selected";
$cursor = $collection->find();
//If Condition
if (($realtime-timestamp)<=5) {
if (channel<=11) {
if (channel>=36) {
echo “dual band”;
}
}
if (channel>=36) {
if (channel<=11) {
echo “dual band”;
}
} else {
echo “Single band”;
}
foreach ($cursor as $doc) {
var_dump($doc);
}
}
?>