HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/content-sp/work-sp/csp_master_structure.php
<?php
include 'config.php';

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);

/*****structure update */
// $getData = $conn->query("SELECT sub_id,csc_ref_id,parent_id FROM csp_sp_master_structure where csc_ref_id!='' and parent_id!='0' limit 2300,100");
// echo "total ".mysqli_num_rows($getData);
// $i=1;
// while($g = $getData->fetch_assoc()) {

//     $sub_id = $g['sub_id'];
//     $csc_id = $g['csc_ref_id'];
//     $pId = $g['parent_id'];

//     echo '<br>';
//     echo $i.' : '.$sub_id.' : '.$csc_id.' : '.$pId;

//     $checkParent = $conn->query("SELECT parent_id FROM oly_sp_master_structure where sub_id='$csc_id'");
//     $cp = $checkParent->fetch_assoc();
//     if($cp['parent_id'] == '0') {
//         echo 'do nothing';
//     } else {
//         $csc_ref = $cp['parent_id'];
//         $findrealParent = $conn->query("SELECT sub_id FROM csp_sp_master_structure where csc_ref_id='$csc_ref'");
//         $fp = $findrealParent->fetch_assoc();

//         $newParent = $fp['sub_id'];

//         echo "Update csp_sp_master_structure set parent_id='$newParent' where sub_id='$sub_id'";
//         //$conn->query("Update csp_sp_master_structure set parent_id='$newParent' where sub_id='$sub_id'");
        
//     }

//     $i++;
// }

/*******master update */
// $getData = $conn->query("SELECT sub_id,master_id FROM csp_sp_master_structure where csc_ref_id!='' limit 2500,100");
// echo "total ".mysqli_num_rows($getData);
// $i=1;
// while($g = $getData->fetch_assoc()) {

//     $pId = $g['master_id'];
//     $sub_id = $g['sub_id'];

//     echo '<br>';
//     echo $i.' : '.$sub_id.' : '.$pId;
    
//     $checkParent = $conn->query("SELECT master_id FROM csp_sp_master_category where csc_master_id='$pId'");
//     $cp = $checkParent->fetch_assoc();


//         $newParent = $cp['master_id'];
//         if($newParent=='' || $newParent=='0') {
//             echo "do nothing";
//         } else {
//             echo "Update csp_sp_master_structure set master_id='$newParent' where sub_id='$sub_id'";
//             $conn->query("Update csp_sp_master_structure set master_id='$newParent' where sub_id='$sub_id'");
//         }

        

//     $i++;
// }