⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Callback_insert not working



Sanaa Alauddin Khan
  • profile picture
  • Member

Posted 21 July 2015 - 04:38 AM

I am calling a callback_insert but it never goes into that function. i tried var_dump. but i can never see the result. it just loads, saves file and then stops but no record is added to the database. please help.

 

 

Here is the controller code:

 

public function new_user_education()
        {
           
            $userid = $_SESSION['logged_in']["user_profile_id"];
            $now = date("Y-m-d H:i:s");  
            $this->load->library('grocery_CRUD');
            $crud = new grocery_CRUD();
            echo "<h1>Education Details</h1>";
            $crud->set_theme('datatables');
            $crud->set_subject('Education Details');
            $crud->set_table('user_education_details');
          $crud->set_relation('user_profile_id','user_profile','id');
           $crud->where('user_profile_id',$userid);
           // $crud->callback_before_insert(array($this,'user_callback'));
             $crud->required_fields('degree','status','college','address1','address2','city','zip','country');
            $crud->set_relation('country','country','country_name');
            $crud->columns(array('degree','specialization','status','college','address1','address2','city','state','zip','country'));
            $crud->add_fields(array('degree','specialization','status','college','address1','address2','city','state','zip','country'));
            $crud->edit_fields(array('degree','specialization','status','college','address1','address2','city','state','zip','country'));
            $crud->field_type('degree','dropdown',array('1' => 'Bachelors', '2' => 'Diploma','3' => 'Doctorate' , '4' => 'Masters'));
            $crud->field_type('status','dropdown',array('1' => 'Completed', '2' => 'In Progress'));
            $crud->unset_export();
            $crud->unset_print();
          $crud->callback_insert(array($this,'insert_education'));
 

            $output = $crud->render();
            
            $this->_example_output($output);         
        }  

function insert_education($post_array,$primary_key) {
            $user_education_insert = array(
        "id" => $primary_key,
        "user_profile_id" => $_SESSION['logged_in']["user_profile_id"],
                "degree" => $_SESSION['logged_in']["degree"],
                "specialization" => $_SESSION['logged_in']["specialization"],
                'college' =>  $_SESSION['logged_in']["college"],
                'address1' =>  $_SESSION['logged_in']["address1"],
                'address2' => $_SESSION['logged_in']["address2"],
                'city' => $_SESSION['logged_in']["city"],
                'state' => $_SESSION['logged_in']["state"],
                'zip' => $_SESSION['logged_in']["zip"],
                'country' => $_SESSION['logged_in']["country"],
                 "added_on" => date('Y-m-d H:i:s'),         
                "added_by" => 'Web Registration',
        "updated_by" => 'Web Registration'
    );

 var_dump($user_education_insert);
 exit();
  return $this->db->insert('user_education_details',$user_education_insert);
}   

 


Amit Shah
  • profile picture
  • Member

Posted 21 July 2015 - 16:33 PM

1 thing what i noticed u calling the method with $primary key... inserts dont have primary key.. try removing it and seeing.!!


Sanaa Alauddin Khan
  • profile picture
  • Member

Posted 22 July 2015 - 21:11 PM

after debugging, and removing the primary key part i get this error,

"NetworkError: 404 Not Found - http://localhost/ResearchSwift/Userauthentication/new_user_education/insert_validation"


Sanaa Alauddin Khan
  • profile picture
  • Member

Posted 23 July 2015 - 05:23 AM

Thanks alot Amit. The issue was with the $config['base_url'].