Syntax error when doing two updates on a single command

0

I'm trying to perform an update on more than one table in the same query, Local normal wheel, but online gives syntax error in MySQL 5.1.72. What can be done to solve?

$query = 
    "UPDATE isc_products SET prodcurrentinv = 12, prodretailprice = 25, prodprice = 26 WHERE prodcode = 121212121212 LIMIT 1;" . 
    "UPDATE isc_product_variation_combinations SET vcstock = 54 WHERE vcsku = 121212121212 LIMIT 1;";
    $query = $pdo->prepare($query);
    $query->execute();
  

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; 'UPDATE isc_product_variation_combinations SET vcstock = 54 WHERE vcsku = 1212121' at line 1 'in /home/aoculist/public_html/admteste/template/main.php:5 Stack trace: # 0 /home/aoculist/public_html/admteste/template/main.php(5): PDO- > prepare ('UPDATE isc_prod ...') # 1 / home / aoculist / public_html / admteste / index. php (55): include ('/ home / aoculist / ...') # 2 {main} thrown in /home/aoculist/public_html/admteste/template/main.php on line 5

    
asked by anonymous 14.03.2014 / 20:44

1 answer

1

For security reasons, it was not possible to run more than one SQL statement at a time, using MySQL from PHP.

Most recent PDO versions support multiple commands.

  

To run multiple commands at once you need:

     
  • PHP 5.3 +
  •   
  • mysqlnd
  •   
  • Emulated prepared statements. Make sure that PDO :: ATTR_EMULATE_PREPARES is set to 1 (default).   Alternatively you can avoid using prepared statements and use    $pdo->exec directly.
  •   

Source of citation: link

    
15.03.2014 / 12:17