From 5bad00978990bf2381d2c72b3a0fcf1490b1395c Mon Sep 17 00:00:00 2001 From: bjverde Date: Thu, 15 Apr 2021 23:37:38 -0300 Subject: [PATCH] :bug: #195 TFormDinDaoDbms --- .../webform/TFormDinDaoDbms.class.php | 54 ++++++++++--------- .../webform/TFormDinDaoDbms.class.php | 54 ++++++++++--------- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/FormDin5/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php b/FormDin5/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php index 333e18e3..8c02cee8 100644 --- a/FormDin5/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php +++ b/FormDin5/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php @@ -831,34 +831,36 @@ public function getSqlToFieldsFromDatabase() { $res = $this->executeSql($sql); $data = null; $sql = null; - foreach($res as $rownum => $row) - { - $data[$rownum]['COLUMN_NAME'] = $row['NAME']; - $data[$rownum]['COLUMN_DEFAULT']= $row['DFLT_VALUE']; - $data[$rownum]['AUTOINCREMENT'] = $row['PK']; - $data[$rownum]['REQUIRED'] = ( $row['NOTNULL'] == 0 ? 'FALSE' : 'TRUE' ); - $data[$rownum]['DATA_TYPE'] = strtoupper($row['TYPE']); - $data[$rownum]['CHAR_MAX'] = null; - $data[$rownum]['NUM_LENGTH']= 0; - $data[$rownum]['NUM_SCALE'] = 0; - $data[$rownum]['PRIMARYKEY'] = $row['PK']; - if( preg_match('/\(/',$row['TYPE']) == 1 ) + if(is_array($res)){ + foreach($res as $rownum => $row) { - $aTemp = explode('(',$row['TYPE']); - $data[$rownum]['DATA_TYPE'] = $aTemp[0]; - $type= substr($row['TYPE'],strpos($row['TYPE'],'(')); - $type = preg_replace('/(\(|\))/','',$type); - @list($length,$precision) = explode(',',$type); - - if( preg_match('/varchar/i',$aTemp[0]==1) ) { - $data[$rownum]['DATA_LENGTH'] = $length; + $data[$rownum]['COLUMN_NAME'] = $row['NAME']; + $data[$rownum]['COLUMN_DEFAULT']= $row['DFLT_VALUE']; + $data[$rownum]['AUTOINCREMENT'] = $row['PK']; + $data[$rownum]['REQUIRED'] = ( $row['NOTNULL'] == 0 ? 'FALSE' : 'TRUE' ); + $data[$rownum]['DATA_TYPE'] = strtoupper($row['TYPE']); + $data[$rownum]['CHAR_MAX'] = null; + $data[$rownum]['NUM_LENGTH']= 0; + $data[$rownum]['NUM_SCALE'] = 0; + $data[$rownum]['PRIMARYKEY'] = $row['PK']; + if( preg_match('/\(/',$row['TYPE']) == 1 ) + { + $aTemp = explode('(',$row['TYPE']); + $data[$rownum]['DATA_TYPE'] = $aTemp[0]; + $type= substr($row['TYPE'],strpos($row['TYPE'],'(')); + $type = preg_replace('/(\(|\))/','',$type); + @list($length,$precision) = explode(',',$type); + + if( preg_match('/varchar/i',$aTemp[0]==1) ) { + $data[$rownum]['DATA_LENGTH'] = $length; + } + else { + $data[$rownum]['CHAR_MAX'] = 0; + $data[$rownum]['NUM_LENGTH'] = $length; + $data[$rownum]['NUM_SCALE'] = $precision; + } } - else { - $data[$rownum]['CHAR_MAX'] = 0; - $data[$rownum]['NUM_LENGTH'] = $length; - $data[$rownum]['NUM_SCALE'] = $precision; - } - } + }//Fim foreach } } $result = array(); diff --git a/appexemplo_v1.0/app/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php b/appexemplo_v1.0/app/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php index 333e18e3..8c02cee8 100644 --- a/appexemplo_v1.0/app/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php +++ b/appexemplo_v1.0/app/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php @@ -831,34 +831,36 @@ public function getSqlToFieldsFromDatabase() { $res = $this->executeSql($sql); $data = null; $sql = null; - foreach($res as $rownum => $row) - { - $data[$rownum]['COLUMN_NAME'] = $row['NAME']; - $data[$rownum]['COLUMN_DEFAULT']= $row['DFLT_VALUE']; - $data[$rownum]['AUTOINCREMENT'] = $row['PK']; - $data[$rownum]['REQUIRED'] = ( $row['NOTNULL'] == 0 ? 'FALSE' : 'TRUE' ); - $data[$rownum]['DATA_TYPE'] = strtoupper($row['TYPE']); - $data[$rownum]['CHAR_MAX'] = null; - $data[$rownum]['NUM_LENGTH']= 0; - $data[$rownum]['NUM_SCALE'] = 0; - $data[$rownum]['PRIMARYKEY'] = $row['PK']; - if( preg_match('/\(/',$row['TYPE']) == 1 ) + if(is_array($res)){ + foreach($res as $rownum => $row) { - $aTemp = explode('(',$row['TYPE']); - $data[$rownum]['DATA_TYPE'] = $aTemp[0]; - $type= substr($row['TYPE'],strpos($row['TYPE'],'(')); - $type = preg_replace('/(\(|\))/','',$type); - @list($length,$precision) = explode(',',$type); - - if( preg_match('/varchar/i',$aTemp[0]==1) ) { - $data[$rownum]['DATA_LENGTH'] = $length; + $data[$rownum]['COLUMN_NAME'] = $row['NAME']; + $data[$rownum]['COLUMN_DEFAULT']= $row['DFLT_VALUE']; + $data[$rownum]['AUTOINCREMENT'] = $row['PK']; + $data[$rownum]['REQUIRED'] = ( $row['NOTNULL'] == 0 ? 'FALSE' : 'TRUE' ); + $data[$rownum]['DATA_TYPE'] = strtoupper($row['TYPE']); + $data[$rownum]['CHAR_MAX'] = null; + $data[$rownum]['NUM_LENGTH']= 0; + $data[$rownum]['NUM_SCALE'] = 0; + $data[$rownum]['PRIMARYKEY'] = $row['PK']; + if( preg_match('/\(/',$row['TYPE']) == 1 ) + { + $aTemp = explode('(',$row['TYPE']); + $data[$rownum]['DATA_TYPE'] = $aTemp[0]; + $type= substr($row['TYPE'],strpos($row['TYPE'],'(')); + $type = preg_replace('/(\(|\))/','',$type); + @list($length,$precision) = explode(',',$type); + + if( preg_match('/varchar/i',$aTemp[0]==1) ) { + $data[$rownum]['DATA_LENGTH'] = $length; + } + else { + $data[$rownum]['CHAR_MAX'] = 0; + $data[$rownum]['NUM_LENGTH'] = $length; + $data[$rownum]['NUM_SCALE'] = $precision; + } } - else { - $data[$rownum]['CHAR_MAX'] = 0; - $data[$rownum]['NUM_LENGTH'] = $length; - $data[$rownum]['NUM_SCALE'] = $precision; - } - } + }//Fim foreach } } $result = array();