Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "xxx";
- $username = "xxx";
- $password = "xxx";
- $dbname = "xxx";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // tt_content
- $sqlContent = "SELECT * FROM tt_content WHERE tx_flux_column LIKE 'content.%'";
- $resultContent = $conn->query($sqlContent);
- while($row = $resultContent->fetch_array())
- {
- $rowsContent[] = $row;
- }
- $contentsToMigrate = [];
- $i = 0;
- foreach ($rowsContent as &$entry) {
- $contentsToMigrate[$i]["tx_flux_parent"] = $entry["tx_flux_parent"];
- $contentsToMigrate[$i]["tx_flux_column"] = str_replace("content.", "" , $entry["tx_flux_column"]);
- $contentsToMigrate[$i]["uid"] = $entry["uid"];
- $contentsToMigrate[$i]["title"] = $entry["header"];
- $i++;
- }
- foreach ($contentsToMigrate as &$content) {
- $sqlFluid = "SELECT * FROM tt_content WHERE uid =".$content["tx_flux_parent"];
- $resultFluid = $conn->query($sqlFluid);
- $rowsFluid = $resultFluid->fetch_array();
- $xml = simplexml_load_string($rowsFluid["pi_flexform"]);
- $number = intval($content["tx_flux_column"]);
- $id = $xml->data->sheet->language->field->el->section[$number]->itemType->el->field[2];
- $id = $id->value;
- echo '<pre>' . $id[0] . '</pre>';
- if($id){
- $updateSql = "UPDATE tt_content SET tx_flux_column = 'content.".$id."' WHERE uid=".$content['uid'];
- $resultFluid = $conn->query($updateSql);
- }
- var_dump($resultFluid);
- }
- //echo '<pre>' . var_dump($contentsToMigrate) . '</pre>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement