⚠ 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

Problems with $crud->where() and $crud->set_relation()



Robin Leigio Gulo

Robin Leigio Gulo
  • profile picture
  • Member

Posted 20 December 2013 - 03:12 AM

Hi,

 

 

I have problems with $crud->where() and $crud->set_relation(). If i use both of them, it won't work. But it works perfectly if i only using one of them.

 

here is my code:

 

                    $crud->set_table('tbl_user');
                    $crud->columns('user_name','nik','email','contact','description','id_role','status');
                    //$crud->where('status','approved');
                    $crud->unset_read();
                    
                    $crud->fields('user_name','password','nik','email','contact','description','id_role');
                    $crud->set_relation('id_role','tbl_role','role_name');
                    $crud->change_field_type('password', 'password');
                    $crud->callback_before_insert(array($this,'encrypt_password'));
                    
                    $dataContent1['admin_content'] = $crud->render();
 
Anyone can help? why this method conflicts each other?

 


Robert

Robert
  • profile picture
  • Member

Posted 20 December 2013 - 07:33 AM

What is the problem i use where and relations with no problems in a loot of functions, i even extended to where_in so i can easy use arrays ...


Robin Leigio Gulo

Robin Leigio Gulo
  • profile picture
  • Member

Posted 23 December 2013 - 07:35 AM

Problem solved.

 

Both tbl_user and tbl_role has field 'approval status' which conflicts. To prevent this, i added tbl_name before field : $crud->where('tbl_user.status','approved');

It works perfectly now. 

 

 

  :D