Tp5 (thinkPHP5) is used to operate mongoDB databases.
This document describes how tp5 (thinkPHP5) operates mongoDB databases. We will share this with you for your reference. The details are as follows:
1. installation through composer
Composer require mongodb/mongodb
2. Use
<? Php/*** @ author: jim * @ date: Jun /11/17 */namespace app \ index \ controller; use think \ Controller; use MongoDB \ Driver \ Manager; use MongoDB \ Collection; class Tests test extends Controller {protected $ pipeline Manager; protected $ pipeline collection; public function _ construct () {$ this-> pipeline Manager = new Manager ($ this-> getUri ()); $ this-> consumer Collection = new Collection ($ this-> consumer manager, "mldn", "dept");} pub Lic function test () {// read a piece of data $ data = $ this-> your collection-> findOne (); print_r ($ data);} protected function getUri () {return getenv ('mongodb _ URI ')? : 'Mongodb: // 127.0.0.1: 27017 ';}}