[Catalyst] strange behavior of catalyst

Will Smith willbelair at yahoo.com
Mon Feb 19 16:21:44 GMT 2007


I'm workng input form and catalyst search funtion with DBIx::Class base model, and found this strange behavior.
  On my input form, there are 7 or more (the form is built dinamically) selection boxes which contains the values : T, F or NA(not null). In the controller, the search string is:
   
  my $val1;
  my $val2;  ... my $val7;
  my $phrase1; .... my $phrase7;
  if($val1 eq "NA"){$phrase1="val1 is not null";} else{$phrase1 = "val1='$val1'";}
  ....
   
  my $searchstring = $phrase1." and ".$phrase2." and ".$phrase3." and ".phrase4." and ".$phrase5." and ".$phrase6." and ".$phrase7;
   
  my $rs = [$c->model('myApp::Mytabe')->search( \$searchstring);   
  # search result is the same for ($searchstring) or ("${searchstring}")
   
  The strang behaviour is:
  if on the form I select less than or equal 3 boxes from val1 to val3 = na, the result returned right. But if I select more than 4 boxes with the val=na, or even 1 box val7=na, catalyst returns error "there is an error in your SQL syntax: .... select val1,val2, ....val7 where val1='T' and val7 is not null and val2='T' and val3='T' and val4 ........ and val6='T' and )
  Please pay attention at the last "and", because the val7 is move next to val1. and this cause the syntax error.
  If the form less that 4 selection box, everything is fine.
   
  Any one could tell me why I get this error. The string is screwed up.
   
  Thank you

 
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your question on Yahoo! Answers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070219/cae1feb8/attachment.htm


More information about the Catalyst mailing list