使用foreach()循环内的占位符将数据插入To wordpress表时,出现此错误。
Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. Please see Debugging in WordPress for more information.
$query = "INSERT INTO competitor_units (competitor_id, unit_size, width, length, square_feet, square_foot_price, unit_price, climate_controlled, amenities, unit_url, scraper_source, latitude, longitude, quantity, hash, last_updated) VALUES ";
foreach ($response as $key => $value) {
array_push($values, $competitor_id, $value['unit_size'], $value['width'], $value['length'], $value['square_feet'], $value['square_foot_price'], $value['unit_price'], $value['climate_controlled'], $value['amenities'], $value['unit_url'], $value['scraper_source'], $value['latitude'], $value['longitude'], 1, $value['hash'], date('Y-m-d H:i:s', strtotime($value['last_updated'])));
$place_holders[] = "('%d', '%s', '%d', '%d','%d', '%d', '%d', '%d', '%s', '%s', '%s', '%d','%d','%d','%s','%s')";
}
$query .= implode(',', $place_holders);
return $this->dbObj->query( $this->dbObj->prepare("$query ", $values));
谢谢。