Is MongoDB the storage I want?

Source: Internet
Author: User
Tags install mongodb mongodb driver

Recently, I have been thinking about the impact of the underlying data model on the entire product. The underlying implementation directly affects the performance and development efficiency of the upper layer, and must meet the needs of fast iteration and rapid product expansion, I have considered the nosql database. I chose MongoDB through comparison. I plan to use it to better understand nosql. I remember what nosql was written by the javaeye boss a few months ago.ArticleI have not thought deeply, but now I need to use it at work. I want to know more about it. MySQL has always been my only choice for databases, however, various MySQL problems have been exposed. In many scenarios, there are actually better practices to replace them. It is beneficial in terms of machine saving and performance, so it takes time to get to know more about MongoDB.

Paste the following information:

MongoDB official website http://www.mongodb.org

Don't Zhou Shan blog on MongoDB summary http://www.wentrue.net/blog? P = 772

Superior MongoDB in action http://www.fuchaoqun.com/2010/01/mongodb-in-action/

PPT address: http://www.fuchaoqun.com/2010/01/mongodb-in-action/

MongoDB installation address: http://www.tbdata.org/archives/410

PHP install MongoDB driver http://cn.php.net/manual/en/mongo.installation.php#mongo.installation.nix

Official Document http://www.mongodb.org/pages/viewpage.action? Pageid = 5079170

Http://www.mongodb.org/display/DOCS/Schema+Design

Introduction to http://www.infoq.com/cn/news/2010/04/mongodb on infoq

Support Document http://php.net/manual/en/book.mongo.php on PHP

Next, I will show my installation results, which is a record of my work tonight. First, I ran my environment and used it. After I tried it, I felt it was powerful.

After successful installation, I directly used synaptic packages manager in Ubuntu to install ipv_^ without any computing content. However, the machine does not support 64-bit installation of virtual machines.

 

The next step is to use MongoDB in PHP .....

1. install PHP Mongo support (if the phpize error is reported here, install php5-dev, sudo apt-Get install php5-dev

2. After Mongo is installed, if it cannot be started, please link ln-S/usr/lib/xulrunner-1.9.2.12/libw.js. So/usr/lib/libw.js. So after the link can be started.

3.

4. After installing PHP support

5. After the installation is successful, new Mongo () retrieves the instance and prints the result.

6. Share the MongoDB class written by superior students ......

PostSuperiorCola_com_mongo, the PHP operation class written in MongoDB, knows how to perform the operation at a Glance. For detailed operation statements, see the superior PPT.

 

<? Phpclass cola_com_mongo {protected $ _ Mongo, $ _ dB;/*** constructor ** @ Param array $ config */public function _ construct ($ Config = array ()) {$ Config = (array) $ config + array ('server' => 'mongodb: // localhost: 100 ', 'options' => array ('connect '=> true); extract ($ config); $ this-> _ Mongo = new Mongo ($ server, $ options ); if (isset ($ database) $ this-> dB ($ database); If (isset ($ user) & isset ($ password )) $ this-> auth ($ user, $ password );} /*** authenticate ** @ Param string $ user * @ Param string $ password */Public Function auth ($ user, $ password) {$ result = $ this-> _ DB-> authenticate ($ user, $ password); if (1 = $ result ['OK']) {return true ;} throw new cola_exception ('mongo auth failed: Bad user or password. ');}/*** select database ** @ Param string $ db * @ return MongoDB */Public Function dB ($ database = NULL) {if ($ database) {$ this-> _ DB = $ this-> _ mongo-> selectdb ($ database);} return $ this-> _ dB ;} /*** select collection *** @ Param string $ Collection * @ return mogocollection */Public Function collection ($ collection) {return $ this-> _ DB-> selectcollection ($ collection );} /*** consumer ID ** @ Param string $ id * @ return consumer ID */public static function ID ($ id = NULL) {return new consumer ID ($ id );} /*** specify timestamp ** @ Param int $ sec * @ Param int $ Inc * @ return specify timestamp */public static function timestamp ($ sec = NULL, $ Inc = 0) {If (empty ($ Sec) $ sec = Time (); return new hour timestamp ($ sec, $ Inc );} /*** gridfs *** @ return response gridfs */Public Function gridfs ($ prefix = 'fs ') {return $ this-> _ DB-> getgridfs ($ prefix );}}

 

Database Design tools in MongoDB

After comparing several management tools, we chose the open-source rockmongo management tool, which is similar to phpMyAdmin.

: Http://code.google.com/p/rock-php/wiki/rock_mongo_zh

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.