I am trying to insert data into a table named class_record in a MySQL database. My controller class aadd_record is written in my add_record.php file.
class Add_record extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->model('add_record_model');
}
}
My model add_record_model is as below:
class add_record_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function index()
{
$data = array(
'roll_number' => 15,
'student_name' => 'Dhrubajyoti Baishya',
'branch_code' => 'CS'
);
$this->db->insert('class_record', $data);
}
}
But when I type http://localhost/codeigniter/index.php/add_record in the url, data is not inserted into the database. What is the problem?
die('foo bar');in the model'sindexmethod and see if it's output?die('foo bar');in the model'sindexand the page is blank !. what can be the problem? sorry I am only 3rd day to CI