Hi, I'm using the below code to insert data and if anything is missing or failed to insert I get proper error MSGs (via session)
PHP Code:
if($db->insert($postData)){
return redirect()->to('xxxxxx');
} else{
return redirect()->back()
->with('errors',(object)$db->errors())
->with('warning','Please validate the data')
->withInput();
}
But when rules are set on an attribute to be unique, CI just throw a system error as below
Code:
mysqli_sql_exception #1062
Duplicate entry '2222' for key 'barcode' search →
Code:
SYSTEMPATH\Database\MySQLi\Connection.php at line 295
288 $this->connID->next_result();
289 if ($res = $this->connID->store_result()) {
290 $res->free();
291 }
292 }
293
294 try {
295 return $this->connID->query($this->prepQuery($sql), $this->resultMode);
296 } catch (mysqli_sql_exception $e) {
297 log_message('error', (string) $e);
298
299 if ($this->DBDebug) {
300 throw new DatabaseException($e->getMessage(), $e->getCode(), $e);
301 }
302 }
How can I get the warnings via the session like the above.
Hope my situation is clear.
My Bad, I found the solution.
If anybody get this issue read this
https://www.codeigniter.com/user_guide/l...=is_unique