Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. $servername = "xxx";
  3. $username = "xxx";
  4. $password = "xxx";
  5. $dbname = "xxx";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14.  
  15. // tt_content
  16. $sqlContent = "SELECT * FROM tt_content WHERE tx_flux_column LIKE 'content.%'";
  17. $resultContent = $conn->query($sqlContent);
  18.  
  19. while($row = $resultContent->fetch_array())
  20. {
  21. $rowsContent[] = $row;
  22. }
  23.  
  24.  
  25. $contentsToMigrate = [];
  26. $i = 0;
  27. foreach ($rowsContent as &$entry) {
  28. $contentsToMigrate[$i]["tx_flux_parent"] = $entry["tx_flux_parent"];
  29. $contentsToMigrate[$i]["tx_flux_column"] = str_replace("content.", "" , $entry["tx_flux_column"]);
  30. $contentsToMigrate[$i]["uid"] = $entry["uid"];
  31. $contentsToMigrate[$i]["title"] = $entry["header"];
  32. $i++;
  33. }
  34.  
  35.  
  36.  
  37. foreach ($contentsToMigrate as &$content) {
  38.  
  39. $sqlFluid = "SELECT * FROM tt_content WHERE uid =".$content["tx_flux_parent"];
  40.  
  41.  
  42. $resultFluid = $conn->query($sqlFluid);
  43.  
  44. $rowsFluid = $resultFluid->fetch_array();
  45.  
  46. $xml = simplexml_load_string($rowsFluid["pi_flexform"]);
  47.  
  48. $number = intval($content["tx_flux_column"]);
  49. $id = $xml->data->sheet->language->field->el->section[$number]->itemType->el->field[2];
  50.  
  51. $id = $id->value;
  52. echo '<pre>' . $id[0] . '</pre>';
  53.  
  54.  
  55.  
  56. if($id){
  57. $updateSql = "UPDATE tt_content SET tx_flux_column = 'content.".$id."' WHERE uid=".$content['uid'];
  58.  
  59. $resultFluid = $conn->query($updateSql);
  60. }
  61.  
  62.  
  63. var_dump($resultFluid);
  64.  
  65. }
  66.  
  67.  
  68.  
  69. //echo '<pre>' . var_dump($contentsToMigrate) . '</pre>';
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement