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.rar ( 1.74 MB Download: 4 times )