Last active
December 9, 2015 09:44
-
-
Save hndr91/4530da2d369cc1af740d to your computer and use it in GitHub Desktop.
slim mongo dbConnect
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 | |
class dbConnect { | |
private $con; | |
private $db; | |
function __construct() {} | |
//connect to MongoDB function | |
function connect() { | |
include_once dirname(__FILE__) . '/config.php'; | |
try { | |
//connect to Mongo with default setting | |
$this->con = new MongoClient(); | |
//connect to database | |
$this->db = $this->con->selectDB(DB_NAME); | |
} | |
catch (MongoConnectionException $e) { | |
echo "Cannot Connect to MongoDB"; | |
} | |
return $this->db; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment