2015-08-08 95 views

回答

0

我figuredout所述的方法,以消除錯誤檢查此代碼

<?php 
 
// connect to mongodb 
 
$m = new MongoClient(); 
 

 
$db = $m->local; \t \t \t \t // select a database 
 
$collection = $db->directors; // select a collection (table in old DB) 
 
$cursor = $collection->find(); // view all 
 
foreach ($cursor as $doc) 
 
{ 
 
    var_dump($doc); 
 
} 
 
?>

在上面的代碼中var_dump()功能用於顯示的值或變量,所以如果數據類型你使用它,這也可以給你一個詳細的信息在這種情況下你的數據的大小和長度,並顯示結果也。

這段代碼是關於如何從MongoDB獲取價值並顯示在PHP頁面上。

相關問題