Php 模型文件中未定义Opencart?
嘿,伙计们,我正试图将数据传递给我的模型,但由于某些原因,我一直在模型文件中获取未定义的customitem_id。我正在测试它是否会发送到模型,因此: 代码如下。customer.php文件中的我的控制器文件Php 模型文件中未定义Opencart?,php,opencart,Php,Opencart,嘿,伙计们,我正试图将数据传递给我的模型,但由于某些原因,我一直在模型文件中获取未定义的customitem_id。我正在测试它是否会发送到模型,因此: 代码如下。customer.php文件中的我的控制器文件 $data['customitem_id']= 19; if(isset($this->request->post['customitem_id'])) { $this->request->post['customi
$data['customitem_id']= 19;
if(isset($this->request->post['customitem_id'])) {
$this->request->post['customitem_id'];
}
我的代码来自:
public function editCustomer($customer_id, $data) {
if (!isset($data['custom_field'])) {
$data['custom_field'] = array();
}
$this->db->query("UPDATE " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$data['customer_group_id'] . "', sales_representative = '" . $this->db->escape($data['username']) . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? serialize($data['custom_field']) : '') . "', newsletter = '" . (int)$data['newsletter'] . "', status = '" . (int)$data['status'] . "', approved = '" . (int)$data['approved'] . "', safe = '" . (int)$data['safe'] . "' WHERE customer_id = '" . (int)$customer_id . "'");
$this->db->query("UPDATE " . DB_PREFIX . "custom_item SET customer_id = '" . (int)$customer_id . "' WHERE customitem_id = '" . (int)$customitem_id . "'");
它一直在模型文件中给我一个未定义的变量。我如何确保它发送数据
谢谢您的帮助。看起来您正在向您的editCustomer$customer\u id$data传递数组$data,对吗 请尝试将此更改为:
$this->db->query("UPDATE " . DB_PREFIX . "custom_item SET customer_id = '" . (int)$customer_id . "' WHERE customitem_id = '" . (int)$customitem_id . "'")
到
请注意,我将int$customitem\u id更改为int$data['customitem\u id']您在模型中使用变量$customitem\u id,但在控制器中它是$data['customitem\u id']。您可能只需要将模型中的$customitem_id更改为$data['customitem_id']
$this->db->query("UPDATE " . DB_PREFIX . "custom_item SET customer_id = '" . (int)$customer_id . "' WHERE customitem_id = '" . (int)$data['customitem_id'] . "'")