2013-02-06 22 views
4

我是MongoDB的初學者,使用php進行處理。我使用的是Windows 8(64位),PHP 5.4.3,PHP擴展版本API20100525,TS,VC9和mongodb-win32-x86_64-2.2.2。Php over MongoDB

我試圖從 https://github.com/mongodb/mongo-php-driver/downloads

下載第一包安裝MongoDB的司機和有包裝內10個驅動程序文件。 我試過每個最後四個驅動程序,它們都能夠使用php 5.4 然後找到php.ini文件,並在驅動程序名稱中包含給定的對應行。 (例如:extension = php_mongo-1.3.2RC1-5.4-vc9-x86_64.dll)

但是他們都沒有迴應我。 我試過下面的示例代碼來評估它們。

<?php 

// connect 
$m = new MongoClient(); 

// select a database 
$db = $m->test; 

// select a collection (analogous to a relational database's table) 
$collection = $db->shafny; 

// add a record 
$document = array("name" => "Anderson", "age" => 22); 
$collection->insert($document); 


// find everything in the collection 
$cursor = $collection->find(); 

// iterate through the results 
foreach ($cursor as $document) { 
echo $document["name"] . "\n"; 
} 

?> 

的I得到一個錯誤信息,

致命錯誤:類 'MongoClient' 用C未找到:\ WAMP \ WWW \第5行蒙戈\ test.php的

我希望由於缺乏適當的驅動程序安裝,導致這個未知的類錯誤正在增加。所以請任何人指導我過來這個問題。

回答

2

如果您使用的是WAMP,您應該在C:\ wamp \ bin \ apache的bin文件夾或您的WAMP Apache PHP.ini文件所在的位置編輯PHP.ini文件。或者,如果您使用單獨安裝的Apache編輯其PHP.ini。我想你已經編輯了PHP文件夾中的PHP.ini。

+0

謝謝老闆...... 有用 – Shafny

+0

不客氣:-) –