1

我正在用 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 的表格中?

4

1 回答 1

2
<?php
$db = new Mongo();
$query = $db->dbname->collection->find();

echo '<pre>';

foreach ( $query as $current )
    print_r($current);

echo '</pre>';
?>

应该可以正常工作。

于 2013-05-28T19:37:31.417 回答