Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Add mongodb extensions to yii

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1, version yii-1.1.13.e9e4a0.tar.gz,YiiMongoDbSuite-1.3.6.3.zip 2, plug-in home page http://www.yiiframework.com/extension/yiimongodbsuite 3, download plug-in https://github.com/canni/YiiMongoDbSuite 4, extract it to the yii application plug-in directory app\ protected\ extensions and rename it to YiiMongoDbSuite 5 Modify the self-loading and component configuration in the application main configuration file app\ protected\ config\ main.php 'import' = > array (.' ext.YiiMongoDbSuite.*', / / plug-in root file), 'components' = > array (.' mongodb' = > array ('class' = >' EMongoDB', / / main file 'connectionString' = >' mongodb://127.0.0.1:27017', / / server address' dbName' = > 'myDatabaseName') / / Database name 'fsyncFlag' = > true, / / mongodb ensures that all writes written to the database are securely stored to disk' safeFlag' = > true, / / the state of all write operations waiting to be retrieved And check 'useCursor' = > false, / / set to true, cursor will be enabled),), 6, add a new operation / * UserController new operation * call address: http://.../app/index.php?r=user/indexm*/public function actionIndexm () {$model = new Userm () / / Model object $data = array (/ / Model data 'username'= >' 11111data,); $model- > unsetAttributes (); / / Clean original data $model- > attributes=$data; / / receive new data $model- > save (); / / Save / update (with authentication) $da = User::model ()-> findAll (); / / query print_r ($da); exit ();}

I always have the problem that when I configure it, the new model will make the page inaccessible. Finally, I will change the mongodb://localhost to mongodb://127.0.0.1:27017.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report