我剛開始使用MongoDB。我可以插入在終端新記錄與像蒙戈命令:MongoDb插入錯誤(php) - BSON doc是X字節,最大爲0
db.test.insert({var: 'data' }) .
,我可以用PHP獲得這些記錄,如:
Array
(
[0] => Array
(
[_id] => MongoId Object
(
[$id] => 509d0a4ae6c4d3ca0ba30572
)
[deneme] => 1
)
[1] => Array
(
[_id] => MongoId Object
(
[$id] => 509d09e2a3047c588723f9bf
)
[deneme] =>
[name] => aa
)
)
但我不能像PHP插入記錄:
$m->insert(array(
'url' => 'http://www.query7.com',
'software' => 'wordpress',
'tutorials' => array('php','javascript','web development'),
));
我得到這個錯誤: 致命錯誤:未捕獲異常'MongoException'消息'BSON文檔的大小爲145字節,最大爲0'
我已經測試過不同的php類,但我總是得到相同的錯誤。什麼是「BSON doc的大小」?
謝謝
你插入之前,選擇一個數據庫,並收集後消失? – Petrogad
yes, $ m-> setDatabase(「test」); \t $ m-> setCollection(「test」); \t \t \t $間 - >刀片(陣列( \t 'URL'=> 'http://www.query7.com', \t '軟件'=> '的wordpress', \t '教程'= > array('php','javascript','web development'), \t)); – Musher
您正在嘗試保存大於MongoDB可保存的文檔。 – GBD