此代码将找不到基于ID搜索的记录
$userid = $_GET['id'];
$theObjId = new MongoId($userid);
$connection = new Mongo('localhost');
$db = $connection->test->items;
$item = $db->findOne(array('_id' => $theObjId));
echo 'Item: ' . $item . '
';
echo 'UserID: ' . $userid . '
';
echo 'TheObjID: ' . $theObjId;
$connection->close();
?>
$userid由另一个.php文件中的表单提供
这是输出….
$item: Array
$userid: 4e0dfc8e7bfb8bac12000000
$theObjId: 4e0dfc8e7bfb8bac12000000
输出证明我的变量包含ID