Skip to content

Commit

Permalink
🐛 #195 TFormDinDaoDbms
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Apr 16, 2021
1 parent 76a89d2 commit 5bad009
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 52 deletions.
54 changes: 28 additions & 26 deletions FormDin5/lib/widget/FormDin5/webform/TFormDinDaoDbms.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5bad009

Please sign in to comment.