ZenDB and images

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 27   (RSS)

I am correct that ZenDb does not return images as part of its record set and that we should use getRecords when we want images.

Jeff Shields

Hi Jeff, 

Using getRecords() might be the easiest right now, we're working on other options for ZenDB in future.

Or here's a workaround using a CMSB function that gets you an array:

$rows = DB::select('articles')->toArray();
addUploadsToRecords($rows, $baseTable);
showme($rows);

Or converting it back to a SmartArray and using that.

$rows = DB::select('articles')->toArray();
addUploadsToRecords($rows, $baseTable);
$rows = SmartArray::new($rows);

showme($rows);

foreach ($rows as $record) {
    echo "<h1>$record->name</h1>\n";
    foreach ($record->uploads as $upload) {
        echo "<img src='$upload->urlPath'><br>\n";
    }
}

Hope one of those solutions works for you.  

Cheers!

Dave Edis - Senior Developer
interactivetools.com