Issue with multi records from another table

4 posts by 2 authors in: Forums > CMS Builder
Last Post: April 5, 2010   (RSS)

Re: [aquaman] Issue with multi records from another table

By Chris - April 1, 2010

Hi aquaman,

A "multi value" list field will contain, for example:

tab 1 tab 2 tab 3 tab

... which is represented in both PHP and MySQL as:

"\t1\t2\t3\t"

So, to get the records listed there, you'd need to change that to a comma-separated list, then use MySQL's "IN" operator:

$numsTabbedList = $nl_multiRecord['yachts'];
$numsTabbedList = trim($numsTabbedList);
$numsCommaList = str_replace("\t", ",", $numsTabbedList);

if ($numsCommaList) {
list($yachtsRecords,) = getRecords(array(
'tableName' => 'yachts',
'where' => "num IN ($numsCommaList)",
'allowSearch' => '0',
));
}
else {
$yachtsRecords = array(); // empty array
}


I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Issue with multi records from another table

Thanks Chris, much appreciated.

Re: [aquaman] Issue with multi records from another table

By Chris - April 5, 2010

Hi aquaman,

Glad I could help! :)
All the best,
Chris