⚠ 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 is an archived forum. ⚠

  •     

profile picture

Check record before insert



rdroguett
  • profile picture
  • Member

Posted 22 June 2012 - 08:39 AM

Hi i need check a record before insert to my database. For not have duplicate record on the table.
How its possible?? I try this

public function customers()
{
$crud = new grocery_CRUD();
$crud->set_table('db_clientes');
$crud->set_subject('Cliente');
$crud->display_as('iddb_estados','Estado de Cuenta');
$crud->set_relation('iddb_estados','db_estados','nombre_estado');
$crud->change_field_type('ultima_actualizacion','hidden',date('Y/m/d H:i:s'));
$crud->order_by('nombre_cliente');
$crud->required_fields('nombre_cliente');
[b] $crud->callback_before_insert(array($this,'check_customer'));[/b]

$output = $crud->render();
$this->load->view('back-end/module/mo_customers', $output);
}

fdias
  • profile picture
  • Member

Posted 22 June 2012 - 12:40 PM

If all you need is to avoid duplicates I suggest you create a UNIQUE KEY on MySQL.