Home  >  Article  >  php教程  >  tp5 [Mongodb expansion package usage correction]

tp5 [Mongodb expansion package usage correction]

WBOY
WBOYOriginal
2016-08-04 08:56:261313browse

I wrote a demo earlier that uses mongdb as the database. Although the data in the database can be read, the method of connecting to the database is actually wrong. I will repost the corrected method here. Just make an interface directly, no demo this time.
Visit: http://127.0.0.1/tp5/public/index.php/index/index/list2
Insert data into mongodbfor (var i = 1; i database.php<code class="prettyprint linenums lang-php">'type' => 'thinkmongoConnection',<br> // Server address<br> 'hostname' => '127.0.0.1',<br> // Database name<br> 'database' => 'demo',Controller index.php//Test interface<br> Public function list2(){<br> ​​​​$list= appcommonmodelAdmin::list2();<br>            return json_encode($list);<br> } }Methods in the model
commonmodelAdmin.php //Query user information in batches<br> Public static function list(){<br> <br>           $list=Db::name('text')->field('name,sex,age')->select();<br> Return $ list; <br> }

tp5 [Mongodb expansion package usage correction] tp5.rar ( 1.74 MB Download: 4 times )

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