mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
Merge branch 'master' of https://github.com/top-think/think
This commit is contained in:
@@ -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则切换数据库
|
||||
|
||||
@@ -13,12 +13,16 @@ namespace think\model;
|
||||
use think\Lang;
|
||||
use think\Loader;
|
||||
|
||||
T('modle/adv');
|
||||
|
||||
/**
|
||||
* MongoModel模型类
|
||||
* 实现了ODM和ActiveRecords模式
|
||||
*/
|
||||
class Mongo extends \Think\Model
|
||||
{
|
||||
use \traits\model\adv;
|
||||
|
||||
// 主键类型
|
||||
const TYPE_OBJECT = 1;
|
||||
const TYPE_INT = 2;
|
||||
@@ -164,7 +168,7 @@ class Mongo extends \Think\Model
|
||||
return false;
|
||||
}
|
||||
if (empty($result)) {
|
||||
// 查询结果为空
|
||||
// 查询结果为空
|
||||
return null;
|
||||
} else {
|
||||
$this->checkMongoId($result);
|
||||
@@ -237,9 +241,10 @@ class Mongo extends \Think\Model
|
||||
} else {
|
||||
// 返回数据个数
|
||||
if (true !== $sepa) {
|
||||
// 当sepa指定为true的时候 返回所有数据
|
||||
// 当sepa指定为true的时候 返回所有数据
|
||||
$options['limit'] = is_numeric($sepa) ? $sepa : 1;
|
||||
} // 查找一条记录
|
||||
}
|
||||
// 查找一条记录
|
||||
$result = $this->db->find($options);
|
||||
if (!empty($result)) {
|
||||
if (1 == $options['limit']) {
|
||||
|
||||
@@ -92,6 +92,7 @@ trait View
|
||||
'url' => $url,
|
||||
'wait' => $wait,
|
||||
];
|
||||
IS_AJAX && Config::set('default_return_type', Config::get('default_ajax_return'));
|
||||
if ('html' == Config::get('default_return_type')) {
|
||||
return $this->fetch(Config::get('dispatch_jump_tmpl'), $result);
|
||||
} else {
|
||||
@@ -107,10 +108,10 @@ trait View
|
||||
* @param integer $wait 跳转等待时间
|
||||
* @return void
|
||||
*/
|
||||
protected function error($message, $jumpUrl = '', $wait = 5)
|
||||
protected function error($message, $data = '', $jumpUrl = '', $wait = 5)
|
||||
{
|
||||
$jumpUrl = $jumpUrl ?: 'javascript:history.back(-1);';
|
||||
return $this->result('', $message, 0, $jumpUrl, $wait);
|
||||
return $this->result($data, $message, 0, $jumpUrl, $wait);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,10 +122,10 @@ trait View
|
||||
* @param integer $wait 跳转等待时间
|
||||
* @return void
|
||||
*/
|
||||
protected function success($message, $jumpUrl = '', $wait = 3)
|
||||
protected function success($message, $data = '', $jumpUrl = '', $wait = 3)
|
||||
{
|
||||
$jumpUrl = $jumpUrl ?: $_SERVER["HTTP_REFERER"];
|
||||
return $this->result('', $message, 1, $jumpUrl, $wait);
|
||||
return $this->result($data, $message, 1, $jumpUrl, $wait);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user