⚠ 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_n_n where clause



goFrendiAsgard
  • profile picture
  • Member

Posted 23 August 2012 - 05:11 AM

I've just add where clause to set_relation_n_n.
Here is the changes: https://github.com/s...d/pull/88/files

Here is the usage example:

$crud->set_relation_n_n('teachers',
'sch_schoolyear_subject_teacher', 'sch_teacher',
'schoolyear_subject_id', 'teacher_id', 'name',
null, array('active'=>1));

Hope it will help someone :)

rteranm
  • profile picture
  • Member

Posted 23 August 2012 - 13:00 PM

I will try it, thanks

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 23 August 2012 - 15:17 PM

Just pushed it at the master release if anyone is interested you can download it straight away the nightly version of grocery CRUD.

Thanks [member='goFrendiAsgard'] for the pull request.

John S Renor
  • profile picture
  • Member

Posted 02 September 2012 - 06:16 AM

I wonder how to define where clause in relation table (not selection table)

rat
  • profile picture
  • Member

Posted 07 September 2012 - 07:24 AM

great new feature :)

[quote name='John S Renor' timestamp='1346566604' post='3179']
I wonder how to define where clause in relation table (not selection table)
[/quote]

I was also wondering about same thing. Can I somehow do a where on relation table. It would be very usefull.
For example I have permission table for calendar in my app:

permission (calendar_id, user_group_id, permission_level)

so I would like to do for example[b]--> [/b][i]where permission_level=[something][/i]

ashish_nirkhe
  • profile picture
  • Member

Posted 07 September 2012 - 20:39 PM

Hi [color="#225985"]goFrendiAsgard[/color],
I copied two functions you have modified
1. function get_relation_n_n_unselected_array($field_info, $selected_values) and
2. public function set_relation_n_n($field_name, $relation_table, $selection_table, $primary_key_alias_to_this_table, $primary_key_alias_to_selection_table , $title_field_selection_table , $priority_field_relation_table = null, $where_clause = null)

and from my code, I am giving call like:
$crud->set_relation_n_n('user_id', 'user_device', 'user', 'device_id', 'user_id', 'email_address', 'priority', array('user_id'=>2));

but it is still listing all the lines instead of selected rows by where clause

Can you please help?

Thanks a lot :)

Regards,
Ashish Nirkhe

HumbleMonk
  • profile picture
  • Member

Posted 09 September 2012 - 18:15 PM

I want to third the request for a where on the relation table. Having a where on the selection table is great and something that I need, but it's only half the job - I also need to perform a where on the relation table. Would love if this could be added :)

ashish_nirkhe
  • profile picture
  • Member

Posted 11 September 2012 - 19:59 PM

So finally done. I did some changes to few other functions and now it works. It also works with relation table.
so now where can be put for relation or selection table.

Thank you guys :)

tlc033
  • profile picture
  • Member

Posted 25 December 2012 - 11:54 AM

[quote name='ashish_nirkhe' timestamp='1347393589' post='3365']
So finally done. I did some changes to few other functions and now it works. It also works with relation table.
so now where can be put for relation or selection table.

Thank you guys :)
[/quote]

Hi ashish_nirkhe, can you help that changes do you do ?
Thank you.

Christophe Conduché
  • profile picture
  • Member

Posted 25 April 2013 - 15:30 PM

is it available for everybody or is it a test function that has not been included in the master tree of GC ?

 

I need it too...


davidoster
  • profile picture
  • Member

Posted 26 April 2013 - 10:10 AM

It should be there. Try it.


Vic Trigger
  • profile picture
  • Member

Posted 30 May 2013 - 14:41 PM

Works fine, thanks a lot

But please add it to the API documentation http://grocerycrud.com/documentation/options_functions/set_relation_n_n


lgmsampaio
  • profile picture
  • Member

Posted 26 June 2013 - 05:18 AM

Oh, 

 

I didn't know about this "where" feature, until I found this topic.

It definitely should be in the API Docs. 


archerwisdom
  • profile picture
  • Member

Posted 09 October 2013 - 02:49 AM

in the film_actor table, there is no Primary Key.

Can this where clause apply to the relation table that don't have primary key?

 

Looking at the function set_relation_n_n, the where_clause will look for the primary key, but in the film_actor relation table, there is no PK.


DirectWeb
  • profile picture
  • Member

Posted 11 October 2013 - 12:07 PM

very useful goFrendiAsgard thanks but please John make an update in the API-documentation. I've searched over half of a hour and found now that it's already inbuild.


domibln
  • profile picture
  • Member

Posted 19 February 2019 - 10:45 AM

I would like the where clause also apply to the table / view, not only to the add and edit forms. How can I do it? Would appreciate any help.