Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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 对wpdb中的非对象调用成员函数insert()_Php_Wordpress - Fatal编程技术网

Php 对wpdb中的非对象调用成员函数insert()

Php 对wpdb中的非对象调用成员函数insert(),php,wordpress,Php,Wordpress,我正在处理wpdb,在那里我发现了这个错误,我声明了global$wpdb并希望使用$wpdb->insert()插入数据但它显示了此错误我的代码如下: <?php class Customer{ /*Add New Customer*/ public function AddCustomer($customer_data = array()){ global $wpdb; $insert_data = $wpdb -> insert

我正在处理wpdb,在那里我发现了这个错误,我声明了
global$wpdb
并希望使用
$wpdb->insert()插入数据但它显示了此错误我的代码如下:

<?php
class Customer{
    /*Add New Customer*/
    public function AddCustomer($customer_data = array()){
        global $wpdb;

        $insert_data = $wpdb -> insert ( 'customer', array(

            'customer_name' => $customer_data['customer_name'],
            'company_name' => $customer_data['customer_company'],
            'customer_contact' => $customer_data['customer_contact'],
            'address' => $customer_data['customer_address'],
            'customer_bank_acc' => $customer_data['customer_bank'],
            'customer_bank_branch' => $customer_data['customer_branch'],
            'customer_ifsc_code' => $customer_data['customer_ifsc'],
            'customer_gst_no' => $customer_data['customer_gst'],
            'customer_remarks' => $customer_data['customer_remark'],
            'customer_status' => 1,

        ) );
        return true;
    }
}

?>


您尝试过调试什么?运行时,
$wpdb
包含哪些内容?我已经检查了所有列名和表,并且$wpdb对于所有类都是全局的。
var\u dump($wpdb)
?var\u dump($wpdb)=null的输出,那么您的数据库还没有初始化,错误很明显。