Advertisement
Guest User

Untitled

a guest
Oct 25th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.81 KB | None | 0 0
  1. <?php
  2. $conn = null;
  3.  
  4. try
  5. {
  6. $dbhost = "localhost";
  7. $user = "root";
  8. $pass = "vicidialnow";
  9. $dbname = "asterisk";
  10.  
  11. $conn = new mysqli($dbhost, $user, $pass, $dbname);
  12. $conn->set_charset('utf8');
  13. }
  14. catch(mysqli_sql_exception $e)
  15. {
  16. echo $e->getMessage();
  17. echo $e->getTraceAsString();
  18. }
  19.  
  20. try
  21. {
  22.  
  23. $queryS = $conn->stmt_init();
  24. $queryS->prepare("SELECT * FROM vicidial_list WHERE list_id = 1240 AND status LIKE 'INT'");
  25. $queryS->execute();
  26. $queryS->store_result();
  27. $queryS->bind_result($lead_id, $entry_date, $modify_date, $status, $user, $vendor_lead_code, $source_id, $list_id,
  28. $gmt_offset_now, $called_since_last_reset, $phone_code, $phone_number, $title, $first_name, $middle_initial, $last_name,
  29. $address1, $address2, $address3, $city, $state, $province, $postal_code, $country_code, $gender, $date_of_birth, $alt_phone, $email,
  30. $security_phrase, $comments, $called_count, $last_local_call_time, $rank, $owner, $entry_list_id);
  31.  
  32. $insertList = "INSERT INTO vicidial_list (entry_date, modify_date, status, user, vendor_lead_code, source_id, list_id,
  33. gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name,
  34. address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email,
  35. security_phrase, comments, called_count, last_local_call_time, rank, owner, entry_list_id)
  36. VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  37. $insertCustom = "INSERT INTO custom_1241 (lead_id, nome, indirizzo, codice_fiscale, data_nascita, residenza, operazione_in_corso,
  38. durata, datore_lavoro, decorrenza, altre_trattenute, rata, seconda_trattenuta, commenti)
  39. VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  40. $conn->autocommit(false);
  41. $count = 0;
  42. $inTransaction = false;
  43.  
  44. $listId = 1241;
  45.  
  46. while($queryS->fetch())
  47. {
  48. if($count == 0)
  49. {
  50. if($inTransaction)
  51. {
  52. $conn->commit();
  53. $inTransaction = false;
  54. }
  55. $inTransaction = true;
  56. }
  57.  
  58. $queryI1 = $conn->stmt_init();
  59. $queryI1->prepare("INSERT INTO vicidial_list (entry_date, modify_date, status, user, vendor_lead_code, source_id, list_id,
  60. gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name,
  61. address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email,
  62. security_phrase, comments, called_count, last_local_call_time, rank, owner, entry_list_id)
  63. VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  64.  
  65. $queryI1->bind_param("ssssssssssssssssssssssssssssssssss",
  66. $entry_date, $modify_date, $status, $user, $vendor_lead_code, $source_id, $listId,
  67. $gmt_offset_now, $called_since_last_reset, $phone_code, $phone_number, $title, $first_name,
  68. $middle_initial, $last_name, $address1, $address2, $address3, $city, $state, $province, $postal_code,
  69. $country_code, $gender, $date_of_birth, $alt_phone, $email, $security_phrase, $comments,
  70. $called_count, $last_local_call_time, $rank, $owner, $entry_list_id);
  71. $queryI1->execute();
  72. $new_lead_id = $queryI1->insert_id;
  73. $queryI1->close();
  74.  
  75. $queryS2 = $conn->stmt_init();
  76. $queryS2->prepare("SELECT * FROM custom_1240 WHERE lead_id = ?");
  77. $queryS2->bind_param("s", $lead_id);
  78. $queryS2->execute();
  79. $queryS2->store_result();
  80. $queryS2->bind_result($lead_id_2, $nome, $indirizzo, $codice_fiscale, $data_nascita, $residenza, $operazione_in_corso,
  81. $durata, $datore_lavoro, $decorrenza, $altre_trattenute, $rata, $seconda_trattenuta, $commenti);
  82.  
  83.  
  84. if($queryS2->fetch())
  85. {
  86. $queryI2 = $conn->stmt_init();
  87. $queryI2->prepare("INSERT INTO custom_1241 (lead_id, nome, indirizzo, codice_fiscale, data_nascita, residenza, operazione_in_corso,
  88. durata, datore_lavoro, decorrenza, altre_trattenute, rata, seconda_trattenuta, commenti)
  89. VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  90. $queryI2->bind_param("ssssssssssssss", $new_lead_id, $nome, $indirizzo, $codice_fiscale, $data_nascita,
  91. $residenza, $operazione_in_corso, $durata, $datore_lavoro, $decorrenza, $altre_trattenute,
  92. $rata, $seconda_trattenuta, $commenti);
  93. $queryI2->execute();
  94. $queryI2->close();
  95. }
  96. $queryS2->free_result();
  97. $queryS2->close();
  98.  
  99. $count++;
  100. if($count == 100)
  101. {
  102. if($inTransaction)
  103. {
  104. $conn->commit();
  105. $inTransaction = false;
  106. }
  107. $count = 0;
  108. }
  109. }
  110. if($inTransaction)
  111. $conn->commit();
  112. $inTransaction = false;
  113.  
  114. $queryS->free_result();
  115. $queryS->close();
  116. }
  117. catch(mysqli_sql_exception $e)
  118. {
  119. if($inTransaction)
  120. $conn->rollback();
  121.  
  122. echo $e->getMessage();
  123. echo $e->getTraceAsString();
  124. }
  125.  
  126. $conn->close();
  127. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement