Robert Granlund
asked on
Wordpress UPDATE Query Syntax
I keep getting an error saying there is something wrong with my syntax at line two. I'm using wordpress and not 100% sure how to do multiple updates to the wp_postmeta table:
$update_meta_item = $pdo->prepare("
UPDATE wp_postmeta
SET meta_value = :price WHERE meta_key = '_regular_price' AND post_id = '$prod_id',
meta_value = :price WHERE meta_key = '_price' AND post_id = '$prod_id',
meta_value = :quantity WHERE meta_key = '_stock' AND post_id = '$prod_id'");
try {
$update_meta_item->execute(array(
':quantity'=>$data[16],
':price'=>$data[3])) or die(print_r($update_meta_item->errorInfo()));
echo '<b>'.++$cnt .'</b> -- Product ID: <b>'. $title.' </b> has been updated.<br />';
}
catch(PDOException $aa) {
echo 'ERROR: ' . $aa->getMessage();
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.