本文整理匯總了PHP中MongoDB::authenticate方法的典型用法代碼示例。如果您正苦於以下問題:PHP MongoDB::authenticate方法的具體用法?PHP MongoDB::authenticate怎麽用?PHP MongoDB::authenticate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MongoDB
的用法示例。
在下文中一共展示了MongoDB::authenticate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAuthBasic
public function testAuthBasic()
{
$ok = $this->object->authenticate("testUser", "testPass");
$this->assertEquals($ok['ok'], 1, json_encode($ok));
$ok = $this->object->authenticate("testUser", "bar");
$this->assertEquals($ok['ok'], 0, json_encode($ok));
}
示例2: __construct
public function __construct($host, $port, $name, $username, $password)
{
try {
$client = new \MongoClient("mongodb://{$host}:{$port}");
$this->db = new \MongoDB($client, $name);
$this->db->authenticate($username, $password);
} catch (\MongoException $e) {
die('Connection failed: ' . $e->getMessage());
}
}
示例3: connect
/**
* Establishes connection to database (does not check for DB sanity)
*
* @return boolean
*/
public function connect()
{
$this->numQueries++;
try {
$this->mongo = new Mongo(TeraWurflConfig::$DB_HOST, self::$CONNECTION_OPTIONS);
$this->dbcon = $this->mongo->selectDB(TeraWurflConfig::$DB_SCHEMA);
if (!empty(TeraWurflConfig::$DB_USER) && !empty(TeraWurflConfig::$DB_PASS)) {
$this->dbcon->authenticate(TeraWurflConfig::$DB_USER, TeraWurflConfig::$DB_PASS);
}
} catch (Exception $e) {
$this->errors[] = $e->__toString() . ', caught in ' . __CLASS__ . '::' . __METHOD__ . '()';
$this->connected = $e->getCode();
return false;
}
$this->mergecoll = $this->dbcon->selectCollection(self::$MERGE);
$this->connected = true;
return true;
}
示例4: authenticate
/**
* Wrapper method for MongoDB::authenticate().
*
* @see http://php.net/manual/en/mongodb.authenticate.php
* @param string $username
* @param string $password
* @return array
*/
public function authenticate($username, $password)
{
return $this->mongoDB->authenticate($username, $password);
}