BUG 7902 "Sudden database error" SOLVED

- it was a bug for gropdown in grid with zero option, it is validated and solved now
This commit is contained in:
Erik Amaru Ortiz
2011-10-25 18:54:18 -04:00
parent c115107677
commit c638c88f53

View File

@@ -329,11 +329,11 @@ class Form extends XmlForm
if (isset($v->options[$value])){
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $v->options[$value];
} else {
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
if(trim($query) == '') {
continue;
}
else { // if hasn't options try execute a sql sentence
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
if ($query != '') { // execute just if a query was set, it should be not empty
//we do the query to the external connection and we've got the label
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");//use default connection workflow if connection is not defined. Same as Dynaforms
@@ -348,7 +348,8 @@ class Form extends XmlForm
break;
}
}
//die;
}
}
}
$newValues["{$k}_label"] = isset($values["{$k}_label"]) ? $values["{$k}_label"] : '';
@@ -363,11 +364,15 @@ class Form extends XmlForm
if (isset($v->options[$newValues[$k]])){
$values["{$k}_label"] = $newValues["{$k}_label"] = $v->options[$newValues[$k]];
} else {
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
if(trim($query) == '') {
continue;
}
else {
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
// execute just if a query was set, it should be not empty
if(trim($query) == '') {
continue; //if it is empty string skip it
}
//we do the query to the external connection and we've got the label
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");
$stmt = $con->prepareStatement($query);
@@ -394,12 +399,20 @@ class Form extends XmlForm
$values[$k][$j] = $newValues[$k][$j];
if ($this->fields[$k]->validateValue($newValues[$k][$j], $this )){
// if the dropdown has otions
if (isset($this->fields[$k]->fields[$kk]->options[$vv])){
$values[$k][$j]["{$kk}_label"] = $newValues[$k][$j][$kk . '_label'] = $this->fields[$k]->fields[$kk]->options[$vv];
} else {
}
else { // if hasn't options try execute a sql sentence
$query = G::replaceDataField($this->fields[$k]->fields[$kk]->sql,$values[$k][$j]);
$con = Propel::getConnection($this->fields[$k]->fields[$kk]->sqlConnection!=""?$this->fields[$k]->fields[$kk]->sqlConnection:"workflow");
$stmt = $con->prepareStatement($query);
// execute just if a query was set, it should be not empty
if(trim($query) == '') {
continue; //if it is empty string skip it
}
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
while ($rs->next()){
// from the query executed we only need certain elements