paperpaper.namepaper.groupidpaper.rateModel2->evaluatorevaluator.loginnameevaluator.groupbased on login in private area i can get the condition on model2, $login is printed without problems$user =& JFactory::getUser();$login=$user->username;pr(" papers assigned to : ".$login); return array('loginname' =>$login); ?>I asume I must define as foreign key "group" because is common relationshipalso i set in fields to be retrieved "group"(not sure if necessary)the issue comes on Model 1, I try to get the papers that are asigned to group "X"$group=$row['evaluator']['group'];pr("Group is".$group); return array('grupoid' =>$group); ?>I couldn't get print any value of $group, i don't know how to get it"> condition based on field of model1 belongs to model2 - Forums

Forums

condition based on field of model1 belongs to model2

teldrive 14 Apr, 2014
I have seen recent FAQ about working with 2 models DB on CCv5, just Great

I have 2 db's( papers & evaluators)
papers are related to evaluator only if both has same number in field "group"(because there are 4 evaluators for each paper)

Model1->paper
paper.name
paper.groupid
paper.rate

Model2->evaluator
evaluator.loginname
evaluator.group

based on login in private area i can get the condition on model2, $login is printed without problems
$user =& JFactory::getUser();
$login=$user->username;
pr(" papers assigned to  :   ".$login);
 return array('loginname' =>$login);
 ?>


I asume I must define as foreign key "group" because is common relationship
also i set in fields to be retrieved "group"(not sure if necessary)

the issue comes on Model 1, I try to get the papers that are asigned to group "X"
<?php
$group=$row['evaluator']['group'];
pr("Group is".$group);
return array('grupoid' =>$group);
?>
I couldn't get print any value of $group, i don't know how to get it
teldrive 15 Apr, 2014
Answer
Just to feedback to everyone, I have got it,my main help was this topic
http://www.chronoengine.com/forums/posts/f12/t95836/address-fields-in-array-for-custom-list.html?hilit=join+condition
multiple Models is complex for me because I don't know which one is first
but after some research final conclusion is : use model 1 for main listing fields in order to don't get confussion and model 2 as filtering or reference
[attachment=0]Captura1.JPG[/attachment][attachment=1]Captura2.JPG[/attachment]
My recomendation use front-list->debug to be sure all is working fine
some tricks:
if you set relation "has one" JOIN rule set as paper.id=ator.egrupo
if you set relation "belongs to" JOIN rule set as paper.egroup=ator.id
in my case i had to use an special JOIN condition to get it working, but anyway I had to set one of the previous
<?php
 return array("paper.egrupo = ator.egrupo");
?>
This topic is locked and no more replies can be posted.