Пример #1
0
 protected function checkDatatype(\Database\Datatype $datatype)
 {
     $type = $datatype->getDatatype();
     if ($type == 'blob' || $type == 'text') {
         throw new \Exception(t('Constraint column may not be a blob'));
     }
     if (!is_a($datatype, '\\Database\\Datatype')) {
         throw new \Exception(t('Constraint column is not a data type'));
     }
 }
Пример #2
0
    private function alterColumnParameters(\Database\Datatype $new)
    {
        $table_name = $this->getFullName();
        $column_name = $new->getName();
        $datatype = $new->getDatatype();
        $q[] = $datatype;
        $size = $new->getSize();
        if (!empty($size)) {
            $q[] = '(' . $new->getSize() . ')';
        }
        $q[] = $new->getExtraInfo();
        $new_column_parameters = implode(' ', $q);
        $query = <<<EOF
ALTER TABLE {$table_name} ALTER COLUMN {$column_name} TYPE {$new_column_parameters}
EOF;
        $this->db->exec($query);
    }