Home > php教程 > php手册 > body text

Mongodb 配置 db_name不生效

WBOY
Release: 2016-06-07 11:38:07
Original
1491 people have browsed it

配置文件中,mongo配置下,db_name不生效
配置:<?php <br /> return [<br>     //默认数据库配置<br>     'DB_TYPE'               =>  'mysql',<br>     'DB_HOST'               =>  '127.0.0.1', // 服务器地址<br>     'DB_NAME'               =>  'test',          // 数据库名<br>     'DB_USER'               =>  'root',      // 用户名<br>     'DB_PWD'                =>  'wh111111',          // 密码<br>     'DB_PORT'               =>  '3306',        // 端口<br>     'DB_PREFIX'             =>  '',    // 数据库表前缀<br>     'DB_DEBUG'              =>  TRUE, // 数据库调试模式 开启后可以记录SQL日志 3.2.3新增\<br>     //mongodb<br>     'DB_MONGO' => [<br>         'DB_TYPE'               =>  'mongo',<br>         'DB_HOST'               =>  '127.0.0.1', // 服务器地址<br>         'DB_PORT'               =>  '27018',        // 端口<br>         'DB_NAME'               =>  'myMongo',          // 数据库名<br>         'DB_USER'               =>  '',      // 用户名<br>         'DB_PWD'                =>  '',          // 密码<br>         'DB_PREFIX'             =>  '',    // 数据库表前缀<br>     ]<br> ];model模型:use Think\Model\MongoModel as baseModel;<br> <br> class RequestLogModel extends baseModel {<br> <br>     /**<br>      * 指定model链接的数据库,值为db config的 key<br>      * <br>      * @var string<br>      */<br>     protected $connection = 'DB_MONGO';<br>     <br> }controller中使用:$model = D('RequestLog');<br>         $model->create();<br>         $model->module = "platform";<br>         $model->controller = "RequestLog";<br>         $model->action = "index";<br>         $model->time = strval(time());<br>         $model->add();配置文件中DB_MONGO下的DB_NAME不起作用, 用的是系统默认的数据库配置下的DB_NAME, 但是DB_MONGO配置下的其它参数都有效,操作完之后,用终端show databases; 只有test数据库,数据也存到了test下requestlog集合中,没有myMongo数据库,请知道的兄弟给个解决办法,先谢谢啦

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template