⚠ In case you've missed it we are migrating 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 forum is read-only and soon will be archived. ⚠

set_relation_n_n get values from relation table

set_relation_n_n where clause relation table

  • Please log in to reply
1 reply to this topic

#1 ananina



  • Members
  • Pip
  • 3 posts

Posted 29 January 2015 - 05:30 AM



I have a doubt about set_relation_n_n. I need to show a value from relation table.

In this example http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n  , its like a need to show priority value, conditioned to a where clause from selection_table.


Something like that:


$where = "actor_id = 1"; 

$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'priority', $where);


I've tried with set_model but on read or edit only shows fields the FROM table


Any ideas?



#2 jinbatsu



  • Members
  • PipPip
  • 23 posts

Posted 29 January 2015 - 11:19 AM

In the sample it show the fullname, NOT the priority.
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority');
If you want to add where, you should do like this:
$where = "actor_id = 1"; 
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority', $where);

So, where condition is in the 8 position, not in the 7.

6 position is for display name

7 position is for priority (field name for sorting order ASC).

8 position is for where condition.


Also tagged with one or more of these keywords: set_relation_n_n, where clause, relation table

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users