There is no MONGODB test environment can be installed on the local MongoDB service, here is MongoDB in Windows under the text installation tutorial.
PHP default does not open the MongoDB extension, you need to manually download the MONGO extension on the official website, find a suitable MONGO extension for your system, unzip it into the PHP environment specified in the EXT directory, and add in the php.ini file
Extension=php_mongo.dll
Restart Apache and other servers to take effect.
Download cakephp and MongoDB datasouce from GitHub and install it in the app/plugins/directory
PS: No git comrades do not worry, you can download directly
After the download is complete, you can configure MongoDB in database.php:
var $mongo = Array (
' DataSource ' = ' Mongodb.mongodbsource ',
' Database ' = ' Testmongo ',
' Host ' = ' localhost ',
' Port ' = 27017
);
You can create a model to use it in the controller:
mongb.php
Class Mondb extends Appmodel {
var $name = ' mondb ';
var $primaryKey = ' _id ';
var $useDbConfig = ' MONGO ';
function schema () {
$this->_schema = Array (
' _id ' = = Array (' type ' = ' = ' integer ', ' primary ' = = true, ' length ' = 40),
' a ' = = Array (' type ' = ' string '),
' b ' = = Array (' type ' = ' = ' integer '),
);
return $this->_schema;
}
}
?>
Then you can manipulate MongoDB in the controller:
function Mongo () {
$this-Loadmodel (' mondb ');
$res = Mondb, $this, Save (Array ("a" = "Test MongoDB", "B" =>time ()));
$res = Find (' All '), MONDB, $this
PR ($res);
Exit
}
http://www.bkjia.com/PHPjc/364753.html www.bkjia.com true http://www.bkjia.com/PHPjc/364753.html techarticle There is no MONGODB test environment can be installed on the local MongoDB service, here is MongoDB in Windows under the text installation tutorial. PHP default does not open the MongoDB extension, need to manually to the official website ...