Last active
December 21, 2015 17:28
-
-
Save kejyun/6340273 to your computer and use it in GitHub Desktop.
連線到MongoDB取資料
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 連線到MongoDB | |
$m = new MongoClient("mongodb://帳號:密碼@localhost"); | |
// 選擇資料庫 | |
$db = $m->test; | |
// 選擇資料集 (collection) | |
$collection = $db->test; | |
// 撈取資料 | |
$test = $collection->find(); | |
// 列印結果 | |
foreach ($test as $document) { | |
var_dump($document); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment