foreach只向表中添加1行

时间:2016-03-16 15:59:39

标签: php mysql opencart

我正在使用opencart系统,并且已经为我们公司添加了特定表格。基本上,当我们输入系统时,它会跟上我们的订单。我试图将多个记录添加到表中,但它只适用于第一个记录。

$this->db->query("INSERT INTO " . DB_PREFIX . "customer_orders SET customer = '" . $data['customer'] . "', email = '" . $data['email'] . "', telephone = '" . $data['telephone'] . "', purchase_order = '" . $data['purchase_order'] . "', date_received = '" . $date . "', date_due = '" . $data['date_due'] . "', insurance = '" . $data['insurance'] . "'");

$customer_order = $this->db->getLastId();

foreach ($data['description'] as $description) {
    $this->db->query("INSERT INTO " . DB_PREFIX . "customer_order_description SET customer_order_id = '" . $customer_order . "', description = '" . $description . "'");
}

此项目有2个描述,因此它应将每个描述放在订单描述表中,但它只会执行第一个描述。

0 个答案:

没有答案