PHPでMongoDBを使う
インストール
# port install mongodb # port install php5-mongo
起動
# mongod & --port 27017 --dbpath=/data/db
接続・挿入・閲覧
<?php $mongo = new Mongo(); $db = $mongo->selectDB('testdb1'); $col = $db->createCollection('collection1'); $col->insert(array('key1' => 'val1')); $cursor = $db->collection1->find(); foreach ($cursor as $k => $cur) { echo $cur['_id'], ':', $cur['key1'], "\n"; }