Jump to content


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

ananina

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 29 January 2015 - 05:30 AM

Hello,

 

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

jinbatsu

    Member

  • 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