If a record exist

5 posts by 3 authors in: Forums > CMS Builder
Last Post: February 18, 2020   (RSS)

Sorry for my stupid question: i would like to have a certain behaviour if "reviewRecord" exists, and another behaviour if reviewRecord doesn't exist. How can i make this?

Thank you in advance for your help

Orazio 

Thank You Jerry! But it doesn'work for me.

I have this code 

list($reviewRecords, $reviewMetaData) = getRecords(array(
'tableName' => 'review',
'where' => 'restaurant = ' . getNumberFromEndOfUrl(),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$reviewRecord = @$reviewRecords[0]; // get first record

So i would like to have "no records found" 'where' => 'restaurant = ' . getNumberFromEndOfUrl(), 

Any suggestions about this?

Sorry, I thought that would work

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

instead of using ! (not) try using the empty function since you are testing an array.

$reviewRecord = @$reviewRecords[0]; // get first record

if (empty($reviewRecord))   {
  echo "no records found";
}
Jeff Shields