Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $DBhost="localhost";
- $DBuser="userid"; These are set properly
- $DBpassword="password"; These are set properly
- try {
- # MySQL with PDO_MYSQL
- $conn = new PDO("mysql:host=$DBhost; charset=utf8", $DBuser, $DBpassword);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);}
- catch(PDOException $e) {
- echo $e->getMessage();
- }
- try {
- echo "size of sql = " . sizeof($sql) . "<br />";
- $conn->beginTransaction();
- for($i=0; $i<sizeof($sql); $i++){
- $stmt = $conn->prepare($sql[$i]);
- $stmt->execute($sql[$i]);
- echo "executing " . $sql[$i] . "<br />rn";
- }
- $conn->commit();
- $message = "Player successfully updated !!";
- $json = array('status' => 'success', 'message' => $message);
- $json_data = json_encode($json);
- echo $json_data;
- return;
- } catch (PDOException $e) {
- $conn->rollback();
- $message = "Could not process transaction. Error:" . $e->getMessage();
- $json = array('status' => 'failure', 'message' => $message);
- $json_data = json_encode($json);
- echo $json_data;
- return;
- }
- size of sql = 7
- executing INSERT INTO bowlingt_lg_shared.player_changes (change_date, change_text) VALUES ('2016-06-21', 'Player ID # 1812(Brady Jr., Tom - LB - MIN) name had changed from Brady Jr., Tom to Brady, Tom')
- executing INSERT INTO bowlingt_lg_shared.player_changes (change_date, change_text) VALUES ('2016-06-21', 'Player ID # 1812(Brady Jr., Tom - LB - MIN) tm_id had changed from 9022 to 9003')
- executing INSERT INTO bowlingt_lg_shared.player_changes (change_date, change_text) VALUES ('2016-06-21', 'Player ID # 1812(Brady Jr., Tom - LB - MIN) pos had changed from LB to QB')
- executing INSERT INTO bowlingt_lg_shared.player_changes (change_date, change_text) VALUES ('2016-06-21', Player ID # 1812 (Brady Jr., Tom - LB - MIN) has changed eligible positions from QB, R, LB, DEF to QB, RB, R, K)
- executing INSERT INTO bowlingt_lg_shared.player_changes (change_date, change_text) VALUES ('2016-06-21', 'Player ID # 1812(Brady Jr., Tom - LB - MIN) active had changed from 0 to 1')
- executing INSERT INTO bowlingt_lg_shared.player_changes (change_date, change_text) VALUES ('2016-06-21', 'Player ID # 1812(Brady Jr., Tom - LB - MIN) tm_abbr had changed from MIN to NE')
- executing UPDATE bowlingt_lg_shared.players SET Name = 'Brady, Tom', tm_id = 9003, pos = 'QB', elig_pos = 'QB, RB, R, K', active = 1 WHERE id = 1812
- {"status":"success","message":"Player successfully updated !!"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement