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', '');
- $column_name = 'something1';
- @column_name2 = 1234;
- $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 `column_name` = :column_name WHERE `id` = :id;
- UPDATE test2 SET `column_name` = :column_name2 WHERE `id` =:id;
- ";
- try {
- $stmt = $db->prepare($sql);
- $stmt->bindParam(':column_name', $column_name, PDO::PARAM_STR);
- $stmt->bindParam(':column_name', $column_name2, PDO::PARAM_INT);
- $stmt->bindParam(':id', $id, PDO::PARAM_INT);
- $stmt->execute();
- echo 'done';
- } catch (PDOException $e) {
- echo $e->getMessage();
- die();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement