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

@ -26,6 +26,7 @@
- fixed #9001: Thingy add image broken
- fixed #9386: Gallery: "Image resolutions" issue
- fixed #9342: Thingy - Cannot edit a thing
- fixed #9033: Deleting Linked Thing Field Crashes Thingy
7.6.7
- fixed #9263: Thingy possibleValues processing, and List type autodetection.

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]);
}