Welcome Guest, Not a member yet? Register   Sign In
Why these codes won't insert?

In MY_model,

function add_group() {
  $data = array(
     'name' => 'dentist' ,
     'description' => 'dentist' ,
  $this->db->insert('groups', $data);
  if($this->db->affected_rows() > 0)
   echo 'Data saved.';  
   echo 'Data not saved.';


In my controller:
function add_group() {

The problem here it doesn't insert the record.

When I execute this it says it saved the data successfully.
But when I checked if it really saved I don't see the newly inserted data.

Thank you very much in advanced.

First off you are saying the db insert is taking place in the MY_Model file but in your function call to the database you are calling the dental model. So I don't even know why you are getting a message back because it shouldn't be calling the right function inside the right model.

core: MY_Model (The parent class)
model: dental_model

Hope it's clear to you now.


I just forgot to set the database.php.

problem solved.

I don't understand though, according to your code the add group is inside of the dental model.

Which extends my_model...so anything available to my_model will be available to any other model that extends it. Just like a base controller or anything else in CI (or PHP for that matter) where you can override or extend the original function/method/parent class.

Theme © iAndrew 2016 - Forum software by © MyBB