Have Thingy check for existance of table and column to prevent

SQL from dying.
This commit is contained in:
Colin Kuskie 2009-01-05 18:09:52 +00:00
parent 6964c2f1d2
commit ee66303d56
2 changed files with 5 additions and 3 deletions

View file

@ -914,15 +914,16 @@ sub getFormElement {
$class = 'WebGUI::Form::'. $param{fieldType};
my $options = ();
my $tableName = 'Thingy_'.$otherThingId;
my ($otherThingTableExists) = $db->quickArray('show tables like ?',[$tableName]);
my $fieldName = 'field_'.$data->{fieldInOtherThingId};
my ($otherThingTableExists) = $db->quickArray('show tables like ? ?',[$tableName, $fieldName]);
if ($otherThingTableExists){
$options = $db->buildHashRef('select thingDataId, '
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId})
.$dbh->quote_identifier($fieldName)
.' from '.$dbh->quote_identifier($tableName));
my $value = $data->{value} || $data->{defaultValue};
($param{value}) = $db->quickArray('select '
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId})
.$dbh->quote_identifier($fieldName)
.' from '.$dbh->quote_identifier($tableName)
.' where thingDataId = ?',[$value]);
}