title: Handle database error in CodeIgniter
body: <p>I'm getting the following error while executing database query:</p>
  
  <pre><code>Error Number: 1062
  
  Duplicate entry '1' for key 1
  
  INSERT INTO `message_template` (`id`, `name`, `subject`, `detail`, `type`,
                                 `status`, `create_date`) 
  VALUES (1, 'adaa', '', 'dss', 'SMS', 'Active', '2011-08-25 19:34:08')
  
  Filename: C:\AppServ\www\ci\system\database\DB_driver.php
  
  Line Number: 330
  </code></pre>
  
  <p>How can I get the error number (e.g. <code>1062</code>) to handlle error?</p>
  
  <p>Thank you</p>