1

My Codeigniter Model Code is below

$last_qt_pk_id  = "";
$i = 0;
foreach($query->result() as $row){
    $data [] = $row;
    $rq_pk_id   = $row->id;
    $question_type_pk_id = $row->question_type_pk_id;
    if($question_type_pk_id != $last_qt_pk_id){
        $i =1;
    } else {
        ++$i;
    }
    $up_data = array('receive_serial_ato_qt'=>$i);
    $this->db->where('id',$rq_pk_id);
    $this->db->update('qms_received_question_info',$up_data);

    $last_qt_pk_id = $question_type_pk_id;
}

My Above Code Firstly it do update, then the question list display in view.

My Code is working nicely but sometimes the problem/error is showing.

My Error is given below by image

enter image description here

I cannot understand that why is showing the error sometimes. If i restart xampp then it has ok for some time but after some time then the error is showing again. I have tried with wamp and xampp but it is showing same problem.

Please, any help?

MD. ABDUL Halim
  • 712
  • 3
  • 11
  • 32

1 Answers1

0

This error is entirely MySQL not doing as it should. The best solution is to forget about MySQL and migrate to other SQL like PostgreSQL, but lacking this option, maybe the following will help you:

also consider increasing the "innodb_lock_wait_timeout" value, and stop using active records when working with transactions.

Personally i don't use active records as it takes a lot of memory and slows the performance time

Azrael
  • 193
  • 8