update : 2015.11.03
php.shukuma.com

검색:
 
 
Creates a new database

MongoDB::__construct

(PECL mongo >=0.9.0)

MongoDB::__constructCreates a new database

설명

public MongoDB::__construct ( MongoClient $conn , string $name )

This method is not meant to be called directly. The preferred way to create an instance of MongoDB is through MongoClient::__get() or MongoClient::selectDB().

If you're ignoring the previous paragraph and want to call it directly you can do so:

<?php

$m 
= new MongoClient();
$db = new MongoDB($m'mydbname');

?>

But don't. Isn't this much nicer:

<?php

$m 
= new MongoClient();
$db $m->mydbname;

// or, if the name contains weird characters:

$db $m->selectDB('my,db:name');

?>

인수

MongoClient conn

Database connection.

name

Database name.

반환값

Returns the database.

오류/예외

Throws default exception if the database name is invalid.