我使用PHP查询MongoDB,我希望在表格中显示集合的所有数据。
以下是我要撤回的数据的部分示例:
Array (
[0] => Array (
[transactions] => Array (
[_id] => 729cfe7c462089e204000000
[propertyId] => 729cfe01462089e104000000
[chargedTo] => tenant
[tenantId] => 729cfe5f462089c104000000
[category] => rent
[amount] => 1000
[paymentMethod] => cheque
[datedAt] => 2013-01-01
[status] => paid
[attachmentUrl] =>
[attachmentName] =>
[description] =>
[emailTenant] => 0
[paidAt] =>
[createdAt] => 2013-03-23T00:49:48.350Z
[accountId] => 729cfc194620897c03000000
[alert] =>
)
)
[1] => Array (
[transactions] => Array (
[_id] => 729cfe93462089ea04000000
[propertyId] => 729cfe01462089e104000000
[chargedTo] => tenant
[tenantId] => 729cfe5f462089c104000000
[category] => rent
[amount] => 5000
[paymentMethod] => cheque
[datedAt] => 2013-03-22
[status] => paid
[attachmentUrl] =>
[attachmentName] =>
[description] =>
[emailTenant] => 0
[paidAt] =>
[createdAt] => 2013-03-23T00:49:48.350Z
[accountId] => 729cfc194620897c03000000
[alert] =>
)
)
.
.
.
[n] => Array (
[transactions] => Array (
[_id] => 729cfea54620897c03000001
[propertyId] => 729cfe01462089e104000000
[chargedTo] => tenant
[tenantId] => 729cfe5f462089c104000000
[category] => rent
[amount] => 2222
[paymentMethod] => Paypal
[datedAt] => 2013-03-05
[status] => paid
[attachmentUrl] =>
[attachmentName] =>
[description] =>
[emailTenant] => 0
[paidAt] =>
[createdAt] => 2013-03-23T00:49:48.350Z
[accountId] => 729cfc194620897c03000000
[alert] =>
)
)
)
如何让所有这些数据显示在PHP的表格中?
答案 0 :(得分:2)
<?php
$db = new Mongo();
$query = $db->dbname->collection->find();
echo '<pre>';
foreach ( $query as $current )
print_r($current);
echo '</pre>';
?>
应该可以正常工作。