⚠ 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

set_relation with OR operator



Marius_LT
  • profile picture
  • Member

Posted 07 January 2015 - 07:43 AM

Hi,

Could you please advise if is there any possibility in set_relation method specify OR operator joining two tables

 

Currently i have:

$crud->set_table('lm_users');
$crud->set_relation('ko_id','lm_ko','ko_name',array('ko_deleted' => 0,'ko_dr_id' =>$this->session->userdata('dr_id')),'id');  

it generates sql like this:

select * from lm_users
join lm_ko on ko_id=id
where ko_deleted=0 and ko_dr_id={$this->session->userdata('dr_id'))}
 

I need where clause like this:

select * from lm_users
join lm_ko on ko_id=id
where (ko_deleted=0 and ko_dr_id={$this->session->userdata('dr_id'))}) OR ko_id=-1

How could i solve such problem?

 

Thank you!


Marius_LT
  • profile picture
  • Member

Posted 07 January 2015 - 11:49 AM

I found workaround using callback_add_field and callback_edit_field.

But it would be interesting to know if is there another way :)