Forums

Can I still address queried data in CC5 via "$MyRow"?

JvdStel 04 Apr, 2015
I come from CC3 world, where I could address queried data via "$MyRow->xyz" statement. Seems like this does not work like that anymore in CC5.
Question: How can I address queried data in body statement of custom front list in CC5?
GreyHead 05 Apr, 2015
Hi JvDStel,

Please try $row['xyz'] in CCv5

Bob
JvdStel 10 Apr, 2015
When I do "echo $row['xyz']", it gives me this error:
Fatal error: Cannot use object of type stdClass as array in.....

What's wrong?

Regards, Johan
GreyHead 11 Apr, 2015
Hi JvDStel,

Hmmm sorry, . . . in that case please try $row->xyz

Bob
JvdStel 12 Apr, 2015
Must be something else wrong here. Since I get no data.

I am joining 2 tables, for which I have created 2 models:
Model1: Members
Model2: Teams 

(one member can be in multiple Teams).

I have defined a foreign key in Model2 as "MemberShipId" and have defined a join condition in Teams model like this:
<?php
return array('Teams.MemberShipId' => 'Members.MemberShipId');
?>

Note: Members.MemberShipId is primary key in Members table, but Teams.MemberShipId is not primary key in Teams table, since this table was created in the past via CF3 and has generated primary key "CF_ID". I assumed no problems there...

I have built a select on Lastname in Members table. Debug display shows me this:
.... LEFT JOIN `TeamsTable` AS `Teams` ON `Teams`.`MemberShipId` = 'Members.MemberShipId' WHERE `Members`.`Lastname` LIKE 'abcxyz%' LIMIT 30 ...
What is wrong here?
GreyHead 12 Apr, 2015
Hi Johan,

Hard to say, the MySQL query looks OK - at least the part you have posted does. What happens if you copy and paste the whole query into PHPMyAdmin? You should then see either some results or an error message.

Bob
JvdStel 13 Apr, 2015
Bob,
When I submit the full query in PHPmyAdmin, including the join, it gives me the expected results.

That's why I think I am missing something in CC5. Also when I us the Table option (iso Custom) it only shows data in columns from Members table and not from Teams.

Regards, Johan
JvdStel 18 Apr, 2015
Hi Bob,
I can get the "Display type Custom" to work. Hope you can help me....
I removed the table join I had before. So back to 1 query on 1 table in 1 model. This is the Condition in my Model:

<?php
$Naam = JRequest::getVar('Achternaam', '' , 'post');
$Status = JRequest::getVar( 'Status_lidmaatschap', '' , 'post');

if ($Naam){
	if ($Status){
			return array("Achternaam LIKE" => "$Naam%","Status_lidmaatschap =" => "$Status");
	}else{
		return array("Achternaam LIKE" => "$Naam%");
	}
}elseif ($Status){
			return array("Status_lidmaatschap =" => "$Status");
}else{
	return array("Status_lidmaatschap =" => "dummy");
}

?>


$Naam and $Status parameters are set via an input form in "Front List > List display > Header code". Everything works just fine via "Display type Table", but when I switch to "Custom", using this Body code:

<?php
echo "<br>".$i." ".$row->Voorletters." (".$row->Roepnaam.") ".$row->Tussenvoegsel." ".$row->Achternaam." ".$row->Relatienummer;
?>


.. it gives me rows with empty fields. Strangely enough 14 empty rows, even if I expect 1 or 2.
teldrive 28 Apr, 2015
for me worked like $row['model']['field']
This topic is locked and no more replies can be posted.