2012-03-31 67 views
0

所以,我一直在這個代碼的工作一段時間,但我放棄了,並伸出你們的幫助。我一直在尋找MongoDB和PHP的文檔,但我找不到任何東西。我想要做的就是把示例代碼插入一條記錄:MongoDB插入一個記錄不工作,因爲它應該

$obj = array("title" => "Calvin and Hobbes", "author" => "Bill Watterson"); 

,並重新目的是爲我的項目(如圖所示):

$obj = array($startCol => $startRow); 

的事情是,$ startCol和$ startRow是數組,每次我想運行文檔時都會出現問題。有沒有什麼可笑的簡單我在這裏失蹤?提前致謝。

的多數民衆贊成給我的問題代碼大塊:

$maxRows= count($currentarray); //Outputs 45 
$maxCols= count($currentarray[0]); //Outputs 9 
$currentRow=1; 
$currentCol=1; 

$testing = 1; 

    do { 
    while ($currentCol<$maxCols){ 
     $startCol[] = $currentarray[0][$currentCol]; 
     $startRow[] = $currentarray[$currentRow][$currentCol]; 
     $currentCol++; 
    } 

    $obj = array($startCol => $startRow); 
    $collection->insert($obj); 
    print_r ($collection); 
    if ($currentCol==$maxCols) 
    $currentCol=1; 
    $currentRow++; 
    $testing++; 
    //echo "<br />"; 
    } while ($currentRow<$maxRows); 
+0

跳到我的第一件事是$收集似乎undefined – Goldentoa11 2012-03-31 17:39:50

+0

對不起,集合被定義我只是沒有發佈它。 – EGHDK 2012-03-31 18:10:51

回答

0

我得到的問題是我的輸出語句。所以我的回答很簡單。之後,print_r()我發現我的所有變量實際上都存儲了它們,但在程序結束時我錯誤地調用了它們。

相關問題