MODX Revolution 2.2.4-pl (traditional)
Struggling xPDO newbie again. I have created a model and generated the classes and map for this table via xPDO. The A-Z list (
https://forums.modx.com/thread/81854/xpdo-help-with-select-distinct#dis-post-451623) working but now am having trouble with the second stage where I am attempting to use the letter generated in the A-Z list to list the members with surnames beginning with a letter
How do I use a substring like Left(Surname,1) with getCollection? Is the use of getCollection appropriate for this use?
I have this working:
$output = '';
$sql = "SELECT * FROM csaac_members WHERE LEFT(Surname,1)= 'A' ";
$csaac = $modx->query($sql);
foreach ($csaac as $row) {
$output .= $row['Surname'] .'<br/>';
}
}
return $output;
to produce a list like
Alam
Alde
Armstrong
Asgahari
Ashton
But when I try to do something like this to produce a full listing for each member
$output = '';
$csaacP = "A";
$csaacmember = $modx->getCollection('Members',array('Left(Surname,1)'=>$csaacP));
foreach ($csaacmember as $row) {
$fields = $row->toArray();
$output .= $modx->getChunk('MemberProv', $fields);
}
}
return $output;
I get a blank screen (the chunk works with a query delivering same data from a different collection). All suggestions welcome.