修正mongo模型不能连接及报setField方法不存在的问题

This commit is contained in:
huangdijia
2015-12-17 11:31:14 +08:00
parent c2bca247be
commit 301c1b9f3f
2 changed files with 11 additions and 4 deletions

View File

@@ -65,7 +65,7 @@ class Mongo extends Driver
{
if (!isset($this->linkID[$linkNum])) {
if (empty($config)) {
$config = $this->config['connection'];
$config = $this->config;
}
$host = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '') . '/' . ($config['database'] ? "{$config['database']}" : '');
@@ -95,6 +95,8 @@ class Mongo extends Driver
$this->initConnect($master);
}
$db = $db?$db:$this->config['database'];
try {
if (!empty($db)) {
// 传人Db则切换数据库