Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors',1); // enable php error display for easy trouble shooting
- error_reporting(E_ALL); // set error display to all
- $db = new PDO("mysql:host=localhost;dbname=test", 'root', '');
- $price = '8000';
- $permalink = 'something-good';
- $id = 1;
- // works not with the following set to 0. You can comment this line as 1 is default
- $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
- $sql = "
- UPDATE test SET `permalink` = :permalink WHERE `id` = :id;
- UPDATE test2 SET `price` = :price WHERE `id` =:id;
- ";
- try {
- $stmt = $db->prepare($sql);
- $stmt->bindParam(':permalink', $permalink, PDO::PARAM_STR);
- $stmt->bindParam(':price', $price, PDO::PARAM_INT);
- $stmt->bindParam(':id', $id, PDO::PARAM_INT);
- $stmt->execute();
- echo 'good';
- } catch (PDOException $e) {
- echo $e->getMessage();
- die();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement