Duplicate record in postgresql from CodeIgniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Duplicate record in postgresql from CodeIgniter (/showthread.php?tid=73146) |
Duplicate record in postgresql from CodeIgniter - fatihdilmac - 03-24-2019 Hi Everyone, Before I have used mysql, for insert action my code : // in mymodel public function insertData($table, $data) { $res=$this->db->insert($table, $data); return $db_error = $this->db->error(); } // in my controller $result = $this->mymodel->insertData($mytable, $data); if ($result['code'] == 1062){ echo "dublicate" } However now I am using postgresql and it returns error like this: A PHP Error was encountered Severity: Warning Message: pg_query(): Query failed: ERROR: duplicate key value violates unique constraint "user_keywords_keyword_key" DETAIL: Key (keyword)=(fa) already exists. Filename: postgre/postgre_driver.php Line Number: 242 array(2) { ["code"]=> string(0) "" ["message"]=> string(126) "ERROR: duplicate key value violates unique constraint "user_keywords_keyword_key" DETAIL: Key (keyword)=(fa) already exists." } my question is that how to ignore this error RE: Duplicate record in postgresql from CodeIgniter - ciadmin - 03-24-2019 I don't have an answer to your question, but will remind you of the forum guidelines you agreed to at signup, namely that new users have their first few posts moderated. That is why your second, third & fourth post have not shown up yet either, and they will be deleted. See the link at the top of each subforum ... https://forum.codeigniter.com/misc.php?action=rules&fid=24 RE: Duplicate record in postgresql from CodeIgniter - neuron - 03-25-2019 Did you set your Primary key to Auto Increment? RE: Duplicate record in postgresql from CodeIgniter - fatihdilmac - 03-25-2019 (03-25-2019, 03:25 AM)neuron Wrote: Did you set your Primary key to Auto Increment? Keyword column is unique when user insert a keyword if it is already exist then I get the exeption RE: Duplicate record in postgresql from CodeIgniter - fatihdilmac - 03-30-2019 (03-25-2019, 04:32 AM)fatihdilmac Wrote:(03-25-2019, 03:25 AM)neuron Wrote: Did you set your Primary key to Auto Increment? Yes I have set my primary key auto increment |