15 if (!defined(
'ADODB_DIR'))
die();
26 case 'C':
return 'VARCHAR';
28 case 'X':
return 'LONG';
30 case 'C2':
return 'VARCHAR UNICODE';
31 case 'X2':
return 'LONG UNICODE';
33 case 'B':
return 'LONG';
35 case 'D':
return 'DATE';
37 case 'T':
return 'TIMESTAMP';
39 case 'L':
return 'BOOLEAN';
40 case 'I':
return 'INTEGER';
41 case 'I1':
return 'FIXED(3)';
42 case 'I2':
return 'SMALLINT';
43 case 'I4':
return 'INTEGER';
44 case 'I8':
return 'FIXED(20)';
46 case 'F':
return 'FLOAT(38)';
47 case 'N':
return 'FIXED';
58 $len = $fieldobj->max_length;
60 static $maxdb_type2adodb = array(
72 $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] :
'C';
75 if ($t ==
'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
76 $type = $len == 20 ?
'I8' :
'I1';
78 if ($fieldobj->auto_increment) $type =
'R';
84 function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
87 if ($funsigned) $suffix .=
' UNSIGNED';
88 if ($fnotnull) $suffix .=
' NOT NULL';
89 if ($fautoinc) $suffix .=
' DEFAULT SERIAL';
90 elseif (strlen($fdefault)) $suffix .=
" DEFAULT $fdefault";
91 if ($fconstraint) $suffix .=
' '.$fconstraint;
100 return array(
'ALTER TABLE ' . $tabname .
' ADD (' . implode(
', ',$lines) .
')' );
107 list($lines,$pkey) = $this->
_GenFields($flds);
108 return array(
'ALTER TABLE ' . $tabname .
' MODIFY (' . implode(
', ',$lines) .
')' );
114 if (!is_array($flds)) $flds = explode(
',',$flds);
115 foreach($flds as $k => $v) {
118 return array(
'ALTER TABLE ' . $tabname .
' DROP (' . implode(
', ',$flds) .
')' );
_GenFields($flds, $widespacing=false)
AddColumnSQL($tabname, $flds)
AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
_CreateSuffix($fname, &$ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned)
DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
MetaType($t, $len=-1, $fieldobj=false)
NameQuote($name=NULL, $allowBrackets=false)