Code for Yii framework to connect to mongodb database_php example

WBOY
Release: 2016-08-17 13:02:41
Original
924 people have browsed it

The yii2 framework is an upgraded version of yii. In this article, we explain how to connect to the database mongodb in the yii framework.

Add the following code to the folder common/config/main_local.php:

<?php
return [
'components' => [
'mongodb' => [
'class' => 'yii\mongodb\Connection',
'dsn' => 'mongodb://localhost:27017/数据库名'
],
],
];
Copy after login

The above is the code for connecting the Yii framework to the mongodb database introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the Script House website!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!