14 if (!defined(
'ADODB_DIR'))
die();
30 $len = $fieldobj->max_length;
32 $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->auto_increment;
35 switch (strtoupper($t)) {
43 if ($len <= $this->blobSize)
return 'C';
56 return !empty($fieldobj->binary) ?
'B' :
'X';
59 case 'DATE':
return 'D';
63 case 'TIMESTAMP':
return 'T';
70 case 'INTEGER':
return $is_serial ?
'R' :
'I';
71 case 'TINYINT':
return $is_serial ?
'R' :
'I1';
72 case 'SMALLINT':
return $is_serial ?
'R' :
'I2';
73 case 'MEDIUMINT':
return $is_serial ?
'R' :
'I4';
74 case 'BIGINT':
return $is_serial ?
'R' :
'I8';
81 switch(strtoupper($meta)) {
82 case 'C':
return 'VARCHAR';
83 case 'XL':
return 'LONGTEXT';
84 case 'X':
return 'TEXT';
86 case 'C2':
return 'VARCHAR';
87 case 'X2':
return 'LONGTEXT';
89 case 'B':
return 'LONGBLOB';
91 case 'D':
return 'DATE';
93 case 'T':
return 'DATETIME';
94 case 'L':
return 'TINYINT';
98 case 'I':
return 'INTEGER';
99 case 'I1':
return 'TINYINT';
100 case 'I2':
return 'SMALLINT';
101 case 'I8':
return 'BIGINT';
103 case 'F':
return 'DOUBLE';
104 case 'N':
return 'NUMERIC';
111 function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
114 if ($funsigned) $suffix .=
' UNSIGNED';
115 if ($fnotnull) $suffix .=
' NOT NULL';
116 if (strlen($fdefault)) $suffix .=
" DEFAULT $fdefault";
117 if ($fautoinc) $suffix .=
' AUTO_INCREMENT';
118 if ($fconstraint) $suffix .=
' '.$fconstraint;
143 function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
147 if ( isset($idxoptions[
'REPLACE']) || isset($idxoptions[
'DROP']) ) {
148 if ($this->alterTableAddIndex)
$sql[] =
"ALTER TABLE $tabname DROP INDEX $idxname";
149 else $sql[] = sprintf($this->dropIndex, $idxname, $tabname);
151 if ( isset($idxoptions[
'DROP']) )
155 if ( empty ($flds) ) {
159 if (isset($idxoptions[
'FULLTEXT'])) {
160 $unique =
' FULLTEXT';
161 } elseif (isset($idxoptions[
'UNIQUE'])) {
167 if ( is_array($flds) ) $flds = implode(
', ',$flds);
169 if ($this->alterTableAddIndex) $s =
"ALTER TABLE $tabname ADD $unique INDEX $idxname ";
170 else $s =
'CREATE' . $unique .
' INDEX ' . $idxname .
' ON ' . $tabname;
172 $s .=
' (' . $flds .
')';
174 if ( isset($idxoptions[$this->upperName]) )
175 $s .= $idxoptions[$this->upperName];
_IndexSQL($idxname, $tabname, $flds, $idxoptions)
_CreateSuffix($fname, &$ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned)
MetaType($t, $len=-1, $fieldobj=false)