Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install the mongodb extension in php

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1, View official introduction www.mongodb.org/display/DOCS/PHP+Language+Center

2, Download the driver www.mongodb.org/downloads linux: install pear: sudo apt-get install php5-dev php5-cli php-pear install extension: sudo pecl install mongo enable extension: php.ini add extension=mongo.so win: github.com/mongodb/mongo-php-driver/downloads install extension: Remove php_mongo.dll from the archive (php_mongo-1.3.0-5.2-vc9.dll), put it into the ext directory of php to enable extensions: php.ini add extension=php_mongo.dll 3, restart apache 4, common operations $db = new MongoClient ( "mongodb://example.com:65432" );//join $db = $m->test; //select a database $table = $db->t; //select a collection (table)$table->insert (array("title"=>"1111", "author"=>"lyj"));//insert record $table->ensureIndex ( array( "i" => 1 ) );//add positive (ascending) index to t table i field $one = $table->findOne();//query a record $cursor = $table->find(array ('i '=>array ('$lte'=>5));//i$v){echo $k. ':'.$ v. ', ';}echo '

';}$table->count();

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report