Opencart从2个表中检索数据

时间:2014-11-05 16:50:22

标签: mysql sql opencart jointable

我试图在opencart中加入2个表来制作一份销售报告,为每个订单指定税收(按类别,可以有很多税率)。我只能从1个表中获取值,但不能获得2.

我该怎么做?

<?php   $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order`, `" .     DB_PREFIX . "order_total`");

$ordersr = array();

// Check if there are any rows returned from the query
if ($query->num_rows > 0) {
// Loop through the returned rows for processing
foreach ($query->rows as $result) {
    $ordersr[] = array(
        'order_id'        => $result['order_id'],
        'invoice_no'      => $result['invoice_no'],
        'total'           => $result['total'],
        'order_status_id' => $result['order_status_id'],
        'date_added'      => $result['date_added'],
        'date_modified'   => $result['date_modified'],
        'firstname'       => $result['firstname'],
        'lastname'        => $result['lastname'],
        'payment_country' => $result['payment_country'],
        'payment_method'  => $result['payment_method'],
        'payment_code'    => $result['payment_code'],
        'shipping_method' => $result['shipping_method'],
        'shipping_code'   => $result['shipping_code'],
        'currency_code'   => $result['currency_code'],
        'currency_value'  => $result['currency_value'],
        'order_status_id' => $result['order_status_id'],
        'date_payed'      => $result['date_payed']
    );
}
} ?>

0 个答案:

没有答案