⚠ 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

3 tables cascade relation



marlee

marlee
  • profile picture
  • Member

Posted 13 February 2016 - 00:21 AM

I have this SQL query:

SELECT blokiszkolenszkolenie_id,blokszkolenszkolenie_termin,bloki_szkolen_id,bloki_szkolen_kategorie_nazwa,bloki_szkolen_tresc FROM ps_blokiszkolenszkolenia LEFT JOIN ps_bloki_szkolen ON ps_blokiszkolenszkolenia.blok_szkolen_id = ps_bloki_szkolen.bloki_szkolen_id LEFT JOIN ps_bloki_szkolen_kategorie ON ps_bloki_szkolen.bloki_szkolen_kategoria_id = ps_bloki_szkolen_kategorie.bloki_szkolen_kategorie_id

my model:

[attachment=1070:relation.jpg]

 

and grocerycrud code:

$crud = new grocery_CRUD();
	$crud->set_theme('datatables');
	$crud->set_table('ps_blokiszkolenszkolenia');
	$crud->columns('blokiszkolenszkolenie_id','blokszkolenie_termin','bloki_szkolen_kategorie_id');

	$crud->set_relation('blok_szkolen_id','ps_bloki_szkolen','bloki_szkolen_id');
	$crud->set_relation('bloki_szkolen_kategoria_id','ps_bloki_szkolen_kategorie','bloki_szkolen_kategorie_nazwa');

	$output = $crud->render();
	$this->_example_output($output);
	

I get an error:

Error Number: 1054

Unknown column 'ps_blokiszkolenszkolenia.bloki_szkolen_kategoria_id' in 'on clause'

SELECT `ps_blokiszkolenszkolenia`.*, j592deebc.bloki_szkolen_id AS s592deebc, jad631ab5.bloki_szkolen_kategorie_nazwa AS sad631ab5 FROM `ps_blokiszkolenszkolenia` LEFT JOIN `ps_bloki_szkolen` as `j592deebc` ON `j592deebc`.`bloki_szkolen_id` = `ps_blokiszkolenszkolenia`.`blok_szkolen_id` LEFT JOIN `ps_bloki_szkolen_kategorie` as `jad631ab5` ON `jad631ab5`.`bloki_szkolen_kategorie_id` = `ps_blokiszkolenszkolenia`.`bloki_szkolen_kategoria_id`

Filename: models/Grocery_crud_model.php

how to properly build grocerycrud relation?

 


mckaygerhard

mckaygerhard
  • profile picture
  • Member

Posted 06 October 2016 - 21:11 PM

i have same situation..

 

seems grocery crud only stabliced two tables relations, and not 3 tables

 

i also seems better solution its override fileds with javascript functions but this need jquery stupid complicated solutions

 

so maybe callbacks its the most comprensible for mortals

 

if i find some solutions i'll post here


Francesco Romeo

Francesco Romeo
  • profile picture
  • Member

Posted 14 October 2016 - 18:11 PM

i am also interested in a solution


wanderson.santos01

wanderson.santos01
  • profile picture
  • Member

Posted 11 February 2019 - 18:30 PM

Hello,

In my case, I'd like to set a relation between 3 tables and use a combo with a filter between these 3 tables.

 

So, I had to do a filter before set_relation and use where parameter in the method, like this:

 

$arrFilter = array(1,2,3,4); // Here you do your magic

 

$crud->set_relation('FIELD','TBM','{FIELD}','FIELD IN (' . implode($arrFilter,',') . ')');

 

By default, Grocery CRUD doesn't filter more than one table.