本文整理汇总了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);
}