Welcome Guest, Not a member yet? Register   Sign In
I need a support in Ci4 - Regarding code standard
#1

I have worked in the Performance optimization part of the software in an Organization. I have reduced the Time complexity Min into Sec. For that I have replaced the nested looping statement. And for each iteration Same SQL query will execute so that the performance very poor. Now I have restructure the SQL query using where clause. But I need to get confirmation about the Implementation is correct or not. Kindly share you thoughts. I have attached the code as well.
Here is my CI4 - Model Code:
PHP Code:
        $machine_event_arr = ['ID1','ID2','ID3','ID4'];
        $split_arr = ['0','0','1','1'];
        $array_condition1 $machine_event_arr;
        $array_condition2 $split_arr;
        $x $getdata[0]['downtime_reason_id'];
        $sql "UPDATE `pdm_downtime_reason_mapping` AS t
                SET `downtime_reason_id` = ''+
$x+''
                WHERE "
;

        $placeholders implode(' OR 'array_fill(0count($array_condition1), '(t.machine_event_id = ? AND t.split_id = ?)'));

        $sql .= $placeholders;

        $combinedArray = [];
        foreach ($array_condition1 as $key => $value) {
            $combinedArray[] = $value;
            $combinedArray[] = $array_condition2[$key];
        }

        $query $db->query($sql$combinedArray); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB