我正在尝试使用$ wpdb将一行插入表中。当我运行代码
$wpdb->insert( 'sync_orders', $data);
$last_query = $wpdb->last_query;
它显示错误'你在mysql语法中有错误'。我正在获取最后一个查询,当我将该查询运行到phpmyadmin时,查询工作正常。
我认为$ wpdb存在一些问题,所以我尝试使用mysqli_query()进行相同的查询。但是我又遇到了同样的问题。 任何帮助将不胜感激。
P.S。 :在$ wpdb-> insert()中不使用第三个param $格式,因为我将所有值都插入为字符串。
这是我从$ wpdb
获得的查询INSERT INTO `sync_orders` (`post_author`, `post_title`, `post_date`, `post_status`, `order_key`, `order_currency`, `prices_include_tax`, `customer_ip_address`, `customer_user_agent`, `customer_user`, `created_via`, `cart_hash`, `order_version`, `billing_first_name`, `billing_last_name`, `billing_company`, `billing_email`, `billing_phone`, `billing_country`, `billing_address_1`, `billing_address_2`, `billing_city`, `billing_state`, `billing_postcode`, `shipping_first_name`, `shipping_last_name`, `shipping_company`, `shipping_country`, `shipping_address_1`, `shipping_address_2`, `shipping_city`, `shipping_state`, `shipping_postcode`, `payment_method`, `payment_method_title`, `order_shipping`, `cart_discount`, `cart_discount_tax`, `order_tax`, `order_shipping_tax`, `order_total`, `download_permissions_granted`, `recorded_sales`, `order_stock_reduced`, `edit_lock`, `order_item_name`, `order_item_type`, `qty`, `tax_class`, `product_id`, `variation_id`, `line_subtotal`, `line_total`, `line_subtotal_tax`, `line_tax`, `line_tax_data`, `pa_color`, `pa_size`) VALUES (1, 'Order – February 3, 2017 @ 01:08 PM', '2017-02-03 13:08:50', 'wc-processing', 'wc_order_58948091938b0', 'INR', 'no', '127.0.0.1', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0', '1', 'checkout', '3229e8ee0da4d8ed89d879f4a1ba9dea', '2.6.13', 'sasdf', 'asdf', 'asdfasdf asdf', 'sharad.kalya@techinfini.in', '7565465455', 'IN', 'asdff adf ffasdf', 'asdfsadf sadf', 'goa', 'GA', '454545', 'sasdf', 'asdf', 'asdfasdf asdf', 'IN', 'asdff adf ffasdf', 'asdfsadf sadf', 'goa', 'GA', '454545', 'cod', 'Cash on Delivery', '', '0', '0', '0', '0', '450.00', '1', 'yes', '1', '1487087216:1', 'Product - 1', 'line_item', '1', '', '9', '20', '450', '450', '0', '0', 'a:2:{s:5:\\\"total\\\";a:0:{}s:8:\\\"subtotal\\\";a:0:{}}', 'brown', 'medium')