".print_r($sql,true)."\n"; return $sql; } // return string must begin with space function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) { $suffix = ''; if ($funsigned) $suffix .= ' UNSIGNED'; if ($fnotnull) $suffix .= ' NOT NULL'; if ($fautoinc) $suffix .= ' DEFAULT SERIAL'; elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; if ($fconstraint) $suffix .= ' '.$fconstraint; return $suffix; } function AddColumnSQL($tabname, $flds) { $tabname = $this->TableName ($tabname); $sql = array(); list($lines,$pkey) = $this->_GenFields($flds); return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(',',$lines) . ')' ); } function AlterColumnSQL($tabname, $flds) { $tabname = $this->TableName ($tabname); $sql = array(); list($lines,$pkey) = $this->_GenFields($flds); return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(',',$lines) . ')' ); } function DropColumnSQL($tabname, $flds) { $tabname = $this->TableName ($tabname); if (!is_array($flds)) $flds = explode(',',$flds); foreach($flds as $k => $v) { $flds[$k] = $this->NameQuote($v); } return array( 'ALTER TABLE ' . $tabname . 'DROP (' . implode(',',$flds) . ')' ); } } ?>