Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] Row not found error in embedded perl.



******    message to minivend-users from Chris Rapier <rapier@psc.edu>     ******

The $ref->record_exists($key) is exactly what I was looking for. I don't
think the perl you gave would work in context though. Only because to
define $searches we need to do a database lookup using the key whose
existance we aren't sure of.

However, I was able to use it to rewrite the code for building the
clickbars into something a lot smaller:

[perl catopts]  
   $Scratch->{'subcat_clickbar'} = "";  
   my $ref = $Db{'catopts'};  
   my $rowname= $Values->{'mv_searchspec'}[0];  
   if ($ref->record_exists($rowname)) {  
     my @subcats = split /\,/, $ref->field($rowname, "subcats"); 
     foreach (@subcats) {  
       $Scratch->{'subcat_clickbar'} .= "<a
href=\"$Config->{'VendURL'}/scan/sf=category,subcat,category2,subcat2/se=$rowname/se=$_/os=no/ml=5.html/tf=description,brand\"><img
border=0 src =\"/windfallfoods/images/$_.gif\"></a>";  
     }  
     $Scratch->{'category_title'} = $ref->field($rowname, "title");  
     $Scratch->{'titleimage'} = $ref->field($rowname, "title_image");  
   } else {  
     $Scratch->{'category_title'} = "Your Search";  
     $Scratch->{'titleimage'} = "yrsearchtitle.jpg";  
   }  
   return "";  
[/perl] 




Mike Heins wrote:

> Chris Rapier wrote:
> > For the most part this works fine but if $rowname doesn't actually exist
> > I get the following error:

>   my @subcats = grep $ref->record_exists($_) split /\,/, $searches;
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: