42 if (!defined(
'ADODB_DIR'))
die();
50 var
$typeX =
'TEXT'; ## Alternatively,
set it to VARCHAR(4000)
60 $len = $fieldobj->max_length;
64 switch (strtoupper($t)) {
67 case 'INTEGER':
return 'I';
69 case 'TINYINT':
return 'I1';
70 case 'SMALLINT':
return 'I2';
71 case 'BIGINT':
return 'I8';
72 case 'SMALLDATETIME':
return 'T';
74 case 'FLOAT':
return 'F';
75 default:
return parent::MetaType($t,$len,$fieldobj);
81 switch(strtoupper($meta)) {
83 case 'C':
return 'VARCHAR';
84 case 'XL':
return (isset($this)) ? $this->typeXL :
'TEXT';
85 case 'X':
return (isset($this)) ? $this->typeX :
'TEXT'; ## could be varchar(8000), but we want compat with oracle
86 case 'C2':
return 'NVARCHAR';
87 case 'X2':
return 'NTEXT';
89 case 'B':
return 'IMAGE';
91 case 'D':
return 'DATETIME';
94 case 'T':
return 'DATETIME';
95 case 'L':
return 'BIT';
98 case 'I':
return 'INT';
99 case 'I1':
return 'TINYINT';
100 case 'I2':
return 'SMALLINT';
101 case 'I4':
return 'INT';
102 case 'I8':
return 'BIGINT';
104 case 'F':
return 'REAL';
105 case 'N':
return 'NUMERIC';
116 list($lines,$pkey) = $this->
_GenFields($flds);
117 $s =
"ALTER TABLE $tabname $this->addCol";
118 foreach($lines as $v) {
121 $s .= implode(
', ',$f);
143 if (!is_array($flds))
144 $flds = explode(
',',$flds);
146 $s =
'ALTER TABLE ' . $tabname;
147 foreach($flds as $v) {
148 $f[] =
"\n$this->dropCol ".$this->NameQuote($v);
150 $s .= implode(
', ',$f);
156 function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
159 if (strlen($fdefault)) $suffix .=
" DEFAULT $fdefault";
160 if ($fautoinc) $suffix .=
' IDENTITY(1,1)';
161 if ($fnotnull) $suffix .=
' NOT NULL';
162 else if ($suffix ==
'') $suffix .=
' NULL';
163 if ($fconstraint) $suffix .=
' '.$fconstraint;
239 function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
243 if ( isset($idxoptions[
'REPLACE']) || isset($idxoptions[
'DROP']) ) {
244 $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
245 if ( isset($idxoptions[
'DROP']) )
249 if ( empty ($flds) ) {
253 $unique = isset($idxoptions[
'UNIQUE']) ?
' UNIQUE' :
'';
254 $clustered = isset($idxoptions[
'CLUSTERED']) ?
' CLUSTERED' :
'';
256 if ( is_array($flds) )
257 $flds = implode(
', ',$flds);
258 $s =
'CREATE' . $unique . $clustered .
' INDEX ' . $idxname .
' ON ' . $tabname .
' (' . $flds .
')';
260 if ( isset($idxoptions[$this->upperName]) )
261 $s .= $idxoptions[$this->upperName];
279 if ($ty ==
'T')
return $ftype;
280 return parent::_GetSize($ftype, $ty, $fsize, $fprec);
_GenFields($flds, $widespacing=false)
_CreateSuffix($fname, &$ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned)
_GetSize($ftype, $ty, $fsize, $fprec)
_IndexSQL($idxname, $tabname, $flds, $idxoptions)
AddColumnSQL($tabname, $flds)
DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
MetaType($t, $len=-1, $fieldobj=false)