Skip to content

Instantly share code, notes, and snippets.

@DMcP89
Created May 3, 2015 19:33
Show Gist options
  • Save DMcP89/a72c3e93a13ae836119b to your computer and use it in GitHub Desktop.
Save DMcP89/a72c3e93a13ae836119b to your computer and use it in GitHub Desktop.
PHP mongoDB connection check
<?php
$dbhost = "mongodb://localhost:27017";
$dbConnection = new MongoClient($dbhost);
$db = $dbConnection->test;
$collection = $db->testData;
$document = array("name" => "PHP Insert");
$collection->insert($document);
$results = $collection->findOne(array("_id" => $document['_id']));
$resultValue = $results['name'];
print "Query Results: $resultValue \n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment