For some reason this while loop only fetches the 1st row of the table for an RSS feed. Not sure what is missing…
$output = '';
$now = date('Y-m-d H:i:s');
$mysqli = new mysqli('dbhost', 'username', 'pw', 'dbname');
if($stmt = $mysqli->prepare("SELECT
id,
etitle,
elocation,
edesc,
estartdate,
eenddate
FROM modx_migx_events
WHERE
published=1")){
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id, $etitle, $elocation, $edesc, $estartdate, $eenddate);
while($stmt->fetch()){
if($eenddate >= $now){
$edesc = strip_tags($edesc);
$edesc_trimmed = strlen($edesc) > 600 ? substr($edesc,0,600).'...' : $edesc;
$estartdate_formatted = date("D, d M Y H:i:s O", strtotime($estartdate));
$output .= '<item>
<title>'.$etitle.'</title>
<description>'.$elocation.' - '.$edesc_trimmed.'
'.$estartdate_formatted.'</description>
<guid isPermaLink="false">http://www.ultimusfundsolutions.com/[[~26? &objectID=`[[+id]]`</guid>
<dc:creator>Ultimus Admin</dc:creator>
</item>';
}//end if endddate >= now
}//end while
$stmt->close();
$mysqli->close();
return $output;
}//end if