⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠

How to make a database error handling?

databaseerror InnoDB constraint foreign key message relation

  • Please log in to reply
No replies to this topic

#1 Apostle



  • Members
  • Pip
  • 2 posts

Posted 28 December 2012 - 04:57 PM

I could not do it. Approximate my PHP code:


function index()
$crud = new grocery_CRUD();


// $crud->callback_after_delete(array($this, 'delete_error_number'));
$crud->callback_before_delete(array($this, 'delete_error_number'));


$output = $crud->render();

foreach($output->css_files as $file)
$this->data['link'] .= link_tag(str_replace(base_url(), '', $file))."\n";
foreach($output->js_files as $file)
$this->data['script'] .= script_tag(str_replace(base_url(), '', $file))."\n";
$this->data['output'] = $output->output;

$this->load->view('templates/header', $this->data);
$this->load->view('templates/menu', $this->data);
$this->load->view('myview.php', $this->data);

function delete_error_number($primary_key)
if ($error_number == $x)
$this->form_validation->set_message('delete_error_message', $primary_key.' To ensure reference (referential, relational, many-to-one relationship) integrity of the database can not be removed. This field is used in the child table.');
return FALSE;
return TRUE;

I like the quick response ;-)

Also tagged with one or more of these keywords: databaseerror, InnoDB, constraint, foreign key, message, relation

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users