BUG 7140 -> Fix complete save label with dbarray connection

The fix was completed. Chckgroup, listbox, dropdowns that use dbconnection now save the labels correctly by executing the query as usual
This commit is contained in:
Hugo Loza
2011-07-01 10:15:25 -04:00
parent 17a4f8c1cb
commit 3aa2785ef1
2 changed files with 14 additions and 12 deletions

View File

@@ -296,10 +296,9 @@ class Form extends XmlForm
* @return array
*/
function validateArray($newValues)
{
{
$values = array();
foreach($this->fields as $k => $v) {
if (($v->type != 'submit')) {
if ($v->type != 'file') {
if ( array_key_exists($k,$newValues) ) {
@@ -333,17 +332,19 @@ class Form extends XmlForm
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
//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
$stmt = $con->prepareStatement($query);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
while ($rs->next()) {
list($rowId, $rowContent) = $rs->getRow();
list($rowId, $rowContent) = array_values($rs->getRow());//This to be sure that the array is numeric. Some cases when is DBArray result it returns an associative. By JHL
if ($value == $rowId){
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $rowContent;
break;
}
}
//die;
}
}
$newValues["{$k}_label"] = isset($values["{$k}_label"]) ? $values["{$k}_label"] : '';

View File

@@ -19,8 +19,8 @@ class DBArrayPreparedStatement extends PreparedStatementCommon implements Prepar
}
private function prepareStatement($sql) {
krumo($sql);
return $str;
return $sql;
}
}
@@ -193,7 +193,7 @@ class DBArrayConnection implements Connection {
*/
public function prepareStatement($dataSql) {
$this->dataSql = $dataSql;
return new DBArrayPreparedStatement($this, $dataSql['sql']);
return new DBArrayPreparedStatement($this, $this->dataSql);
}
/**
@@ -242,6 +242,7 @@ class DBArrayConnection implements Connection {
return;
}
$sql = array();
$sql['selectClause'][0] = isset($matches[1]) ? $matches[1] : '';//Include selectClause. By JHL
$sql['fromClause'][0] = isset($matches[2]) ? $matches[2] : '';
$sql['whereClause'][0] = isset($matches[3]) ? $matches[3] : '';
$sql['limit'] = 0;
@@ -253,8 +254,8 @@ class DBArrayConnection implements Connection {
* @see Connection::executeQuery()
*/
public function executeQuery($sql, $fetchmode = null) {
if (!is_array($sql) && strlen($sql) > 0) {
$sql = $this->parseSqlString($sql);
if (!is_array($sql) && strlen($sql) > 1) {
$this->dataSql=$sql = $this->parseSqlString($sql);
}
$resultSet = new DBArrayResultSet($this, $sql, $fetchmode);
$tableName = $sql['fromClause'][0];
@@ -270,7 +271,7 @@ class DBArrayConnection implements Connection {
if ($key == 0)
continue;
$flag = 1;
if (isset($sql['whereClause']))
if (isset($sql['whereClause'])){//If there is no where then return the row
foreach ($sql['whereClause'] as $keyClause => $valClause) {
if (isset($valClause) && $flag == 1) {
//$toEval = "\$flag = ( " . ($valClause != '' ? str_replace('=', '==', $valClause): '1') . ') ?1 :0;' ;
@@ -298,14 +299,14 @@ class DBArrayConnection implements Connection {
eval($toEval);
}
}}else{
}
if ($flag) {
$resultRow[] = $row;
}
}
if ($this->dataSql['selectClause'][0] == 'COUNT(*)') {
$rows[] = array('1' => 'integer');
if (isset($resultRow) && is_array($resultRow))