Search code examples
phpcodeignitermultiple-conditionsbatch-updates

Multiple WHERE condition issue at update_batch in CodeIgniter


Facing problem to used multiple Where condition at update_batch in CodeIgniter.

No error message is not showing . As well as Data is not updating at database. But after click Submit Button is giving me flash message as Data is submitted successfully. But Database could not be able to Update. Please suggest me what should I do !

Controller ------------------------------------

public function masterPrice_update($m_fran_id = null) 
	{
		$sID   = $this->input->post('m_test_id');
		$sAmt  = $this->input->post('m_updated_test_price');
		$sFranId = $this->input->post('m_fran_id');

		for ($i= 0; $i < count($sID); $i++)
		{
			
			$edited_test[] = array(
				'm_test_id' => $sID[$i],
				'm_updated_test_price' => $sAmt[$i],
				'm_fran_id' => $sFranId[$i]
			);
		}

		if ($this->form_validation->run() === true) {
			$this->franchise_price_model->singlebatch_Test_updt($edited_test);

			$this->session->set_flashdata('message', display('save_successfully'));
			redirect('branch/franchise_price/masterPrice_update');
		}
	}

Modal ---------------------

public function singlebatch_Test_updt($edited_test =[], $sFranId ='')
{	
	$this->db
	->where('m_fran_id',$sFranId)
	->update_batch($this->fran_test_pricemaster, $edited_test , 'm_test_id' );
}


Solution

  • You can use $this->db->last_query() to print query. I think you have issue in where condition from controller you are not passing $sFranId to model.