• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error Handling while using $this->db->insert

#1
[eluser]Unknown[/eluser]
<?php
class imrtrackerModel extends CI_Model {

private $imrmain= 'imrmain';

function imrtracker(){
parent::__construct();
}

function save($imrtracker){
try
{
$rc_save = $this->db->insert($this->imrmain, $imrtracker);
echo 'outside error';
if (! $rc_save)
{
throw new Exception();
}
}

catch (Exception $e)
{
echo 'exception';
}

}

}
?>

The above is my model code. I want to capture the duplicate entries. But i am not able to handle the error. Kindly help me. Am new to Codeigniter.

#2
[eluser]InsiteFX[/eluser]
CodeIgniter User Guide - Query Helper Functions

#3
[eluser]Mauricio de Abreu Antunes[/eluser]
You dont need to catch exceptions.
If you need to check duplicate entries, run your sql command to get duplicate entries.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.