Welcome Guest, Not a member yet? Register   Sign In
handle error insert database
#1

[eluser]tnathos[/eluser]
hi, i have a table whit 3 fields, field 1 and 2 are the primary key.. i make a insert in the database and works fine.

I need know if the data what send the user exits in the database previuly.. but i dont like make before a insert an select...

I think.. if i try insert.. the db tell me what the data exits.. and i dont insert.. (validate the primary)

But i have a problem.. when make the second insert.. show me a error in text!! and cant catch..

any can help me?

Code:
$set_fav = array (
        'id_usuario' => $this->session->userdata('id'),
        'id_proceso' => $this->session->userdata('id_proceso'),
        'fecha' => date('Y-m-d'));
            
        if($this->db->insert('table',$set_fav))    
            return true; // ok new data
        else
            return false; // fail insert.. doble data for prmary key




Theme © iAndrew 2016 - Forum software by © MyBB