mongoDB easy db creation php
To create a db on runtime from php:
$conn = new Mongo('serverConnectionString');
create a db
$db = $conn->selectDB("dbName");
on the first command like adding a collection to that db will trigger the creation
$db->command(array("create" =>"newCollectionName"));
also security sometime is needed so :
$db->selectCollection("system.users");
$db->insert(array('user' =>"username", 'password'=> md5('password'),'readOnly' => false));
Written by Pedro Aron Barrera Almaraz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#