search
Homephp教程php手册Mongodb 配置 db_name不生效

配置文件中,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元

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use