Reputation: 11
It shows the following error and no new collections are created in the mlab database.
Connected
( ! ) Notice: Undefined property: MongoDB\Driver\Manager::$helfis in C:\wamp\www\mongo.php on line 11
Database mydb selected
( ! ) Fatal error: Call to a member function createCollection() on a non-object in > C:\wamp\www\mongo.php on line 13
Here's my PHP Code:
<?php
$m = new MongoDB\Driver\Manager("mongo_url");
echo "Connected";
$db = $m->helfis;
echo "Database mydb selected";
$collection = $db->createCollection("myhell");
echo "Collection created succsessfully";
$collection = $db->dashboard;
echo "Collection selected succsessfully";
?>
Upvotes: 0
Views: 991
Reputation: 11
$command = new MongoDB\Driver\Command(["create" => 'testcollection']);
$cursor = $this->mgoManagerObj->executeCommand("testdb", $command);
$response = $cursor->toArray()[0];
var_dump($response);
Upvotes: 1