Hi,
I am new to grocery crud as well as codeigniter. I am using following function for call_back but I is not working.
I am using 2 tabels
table_city(city_id(primarykey,autoincrement),city_name)
table_route(route_id(primarykey, autoincriment), fromcity_id, fromcity_name, tocity_id,tocity_name)
I am using set_relation for fromcity_id and tocity_id fields from table_route with city_id field in table_city
as with this set_relation I am only able to store city_id in in fromcity_id and tocity_id fields, I would also like to add city_name in fromcity_name and tocity_name fields. so I am using callback_after_insert and update functions to update citynames of the same table. my code as fallows.
public function manageroute() {
$crud = new grocery_CRUD();
$crud->set_table('table_route');
$crud->set_subject('Route');
$crud->set_relation('fromcity_id','table_city','city_name');
$crud->display_as('fromcity_id','city_name');
$crud->set_relation('tocity_id','table_city','city_name');
$crud->display_as('tocity_id','city_name');
$crud->callback_after_insert(array($this, '_update_cityname_after_insert'));
$crud->callback_after_update(array($this, '_update_cityname_after_update'));
$output = $crud->render();
$this->_example_output($output);
}
function _update_cityname_after_insert($post_array,$primary_key)
{
$fquery = $this->db->get_where('table_city', array('city_id' => $post_array['fromcity_id']));
$fromcityname = $fquery->city_name;
$tquery = $this->db->get_where('table_city', array('city_id' => $post_array['tocity_id']));
$tocityname = $tquery->city_name;
$data = array(
'fromcity_name' => $fromcityname,
'tocity_name' => $tocityname
);
$this->db->where('route_id', $primary_key);
$this->db->update('table_route', $data);
return true;
}
even I am not able echo any text from call back function.
am I doing any mistake in above code?