list() question

2 posts by 2 authors in: Forums > CMS Builder
Last Post: December 1, 2010   (RSS)

By zip222 - December 1, 2010

when you generate a list() viewer, there is something I don't quite understand. in the example below I have bolded a few Ss. I am curious why these are here:

// load records
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'limit' => '1',
));
$newsRecord = @$newsRecords[0]; // get first record


There have been times where I have accidentally removed these, but the pages still loaded properly.

Re: [zip222] list() question

By Jason - December 1, 2010

Hi,

$newsRecords and $newsRecord are just variable names. In your example, $newsRecords is an array of records.
In this line:
$newsRecord = @$newsRecords[0]; // get first record
You take the first record from $newsRecords and assign it to a variable called $newsRecord.

You can remove the "s" and it will still work as long as you remove it in both cases.

Hope this helps clarify. Let me know if you have any other questions.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/