Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 模型文件中未定义Opencart?_Php_Opencart - Fatal编程技术网

Php 模型文件中未定义Opencart?

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

嘿,伙计们,我正试图将数据传递给我的模型,但由于某些原因,我一直在模型文件中获取未定义的customitem_id。我正在测试它是否会发送到模型,因此:

代码如下。customer.php文件中的我的控制器文件

        $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'] . "'")