Reputation: 577
I have applied composite Primary key on a table which returns error message if the Primary Key constraint fails, So whenever user enters the duplicate rows the programs throws the following error message.
Duplicate entry '43-15' for key 'uk_sid_coursid'
I want to skip this error message, I want page to redirect to another page myerror.php
where user can go back and update the records. I have use if-else
condition, but still its giving me the same error message. Below is my code,Kindly review it.
MODEL
public function student_marks_fill($student_id, $semester_course_id)
{
$data= array(
"StudentId"=> $student_id,
"SemisterCourseId"=>$semester_course_id
);
if($this->db->insert('student_marks', $data))
{
return true;
}
else
{
return false;
}
}
Controller
if($this->loginmodel->student_marks_fill($id, $semesterCourseId))
{
$this->load->view('admin');
}
else
{
$this->load->view('admin');
}
}
Upvotes: 2
Views: 1873
Reputation: 10717
db_debug - TRUE/FALSE (boolean) - Whether database errors should be displayed.
Set db_debug
as FALSE
in config/database.php
$db['default']['db_debug'] = FALSE;
Documentation: http://ellislab.com/codeigniter/user-guide/database/configuration.html
Upvotes: 4