set_model working but results are getting overwritten by crud
- Single Page
Posted 07 September 2012 - 00:35 AM
I have following in model file:
class custom_model extends grocery_CRUD_Model
{
function join_table($table1, $table2, $userid)
{
//$selection_primary_key = $this->get_primary_key($field_info->device);
//$query = $this->db->query("select * from device join user_device on device.id = user_device.device_id where user_device.user_id = 2");
$this->db->select($table1.".*,".$table2.".*");
$this->db->from($table1);
$this->db->join($table2, $table2.".device_id". "=" .$table1.".id");
$this->db->where("user_device.user_id",$userid);
$results = $this->db->get()->result();
var_dump ($results);
return $result;
}
}
and then in the main function I am having:
$crud->set_model('custom_model');
$this->custom_model->join_table('device','user_device',$userid);
$crud->set_table('device');
$crud->set_theme($this->theme);
$crud->columns('device_id', 'product', 'build', 'description', 'device_status_id', 'preferred_location_id', 'owner_id', 'user_id', 'Access Group', 'showMap', 'Exception');
$crud->set_relation('product','product','name');
$crud->set_relation('build','build','build_id');
$crud->set_relation('owner_id', 'user', 'email_address');
$crud->set_relation('device_status_id', 'device_status', 'name');
$crud->set_relation_n_n('preferred_location_id','location_device','preferred_location','device_id','preferred_location_id','name','priority');
$crud->set_relation_n_n('user_id','user_device','user','device_id','user_id','email_address','priority');
$crud->callback_column('User', array($this, 'getUser'));
$crud->callback_column('Access Group', array($this, 'getAccessGroup'));
$crud->callback_column('showMap', array($this, 'getCoordinate'));
$crud->callback_column('Exception', array($this, 'getException'));
$crud->unset_add();
$crud->unset_edit();
$crud->unset_delete();
$output = $crud->render();
$this->load->view('crud', $output);
now with this code i can see expected result in my var_dump
but in the list, which is being created with crud code, I again see all the records (and not the one restricted by where clause)
Can anyone please help me
Thanks a lot
Posted 07 September 2012 - 18:08 PM
Posted 11 September 2012 - 20:00 PM
so now where can be put for relation or selection table.
Thank you guys
Posted 12 July 2013 - 22:54 PM
how can you did that? please i have the same problem