⚠ 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

WHERE clause missing in model SELECT statement for set_relation_n_n



amityweb
  • profile picture
  • Member

Posted 25 July 2013 - 15:55 PM

I needed to use set_relation_n_n but include a where clause. There are a couple of posts that actually state to pass the where clause as the 8th parameter in the set_relation_n_n() function. 

 

Its included in the set_relation_n_n function in grocery_crud.php:-

 

$this->relation_n_n[$field_name] = 
(object)array( 
'field_name' => $field_name, 
'relation_table' => $relation_table, 
'selection_table' => $selection_table, 
'primary_key_alias_to_this_table' => $primary_key_alias_to_this_table, 
'primary_key_alias_to_selection_table' => $primary_key_alias_to_selection_table , 
'title_field_selection_table' => $title_field_selection_table , 
'priority_field_relation_table' => $priority_field_relation_table,
'where_clause' => $where_clause
);

 

BUT... its missing in the function relation_n_n_queries() in grocery_crud_model.php.

 

So I added it below. 
 

grocery_crud_model.php line 123 for function relation_n_n_queries($select):

     $select .= ", (SELECT GROUP_CONCAT(DISTINCT $field) FROM $selection_table "
     ."LEFT JOIN $relation_table ON $relation_table.$primary_key_alias_to_selection_table = $selection_table.$primary_key_selection_table "
     ."WHERE $relation_table.$primary_key_alias_to_this_table = `{$this->table_name}`.$this_table_primary_key AND $where_clause GROUP BY $relation_table.$primary_key_alias_to_this_table) AS $field_name";

 

 

Can you check, confirm, and add it in, so I dont have to keep a modified version of grocery_crud? 

 

I am using version 1.3.3, I upgraded earlier today. 

 

Thanks

 


davidoster
  • profile picture
  • Member

Posted 25 July 2013 - 23:33 PM

Thank you [member=amityweb] for pointing out this.

We will let [member=web-johnny] know about this and we will come back to you.