Re: [pcolvin] Sorting Uploads
Hi,
All uploads are stored in a separate section called uploads. We access them through the tableName, fieldName, and recordNum of the record we're getting the uploads for. In the uploads section is a field called createdTime, which we can use to do the sorting you want.
What we'll do is select a single record from our section, then do a separate select to get the uploads for that record, ordering them by createdTime.
In this example we're going to use a section called 'listings' which has an upload field called images:
First we select the first record from 'listings':
list($listingsRecords,$listingsMetaData)=getRecords(array(
'tableName' => 'listings',
'allowSearch' => false,
));
$record = $listingsRecords[0]; //get the first record
We now use the record num stored in $record to get the uploads for that record:
list($uploadRecords,$uploadMetaData)=getRecords(array(
'tableName' => 'uploads',
'allowSearch' => false,
'where' => "tableName='listings' AND fieldName = 'image' AND recordNum='".intval($record['num'])."'",
'orderBy' => 'createdTime DESC',
));
The variable $uploadRecords now contains all the uploads for the listings record we selected, ordered by createdTime (most recent first).
Give this a try and let me know if you run into any issues.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/