method getAlterColumn documentation in bbn\Db\Languages\Pgsql
function(string $table, array $cfg)
{
$alter_types = ['add', 'modify', 'drop'];
if (!empty($cfg['alter_type']) && in_array(strtolower($cfg['alter_type']), $alter_types)) {
$alter_type = strtoupper($cfg['alter_type']);
}
else {
$alter_type = 'ADD';
}
$st = '';
if (empty($cfg['no_table_exp'])) {
$st = 'ALTER TABLE '. $this->escape($table) . PHP_EOL;
}
if ($alter_type === 'MODIFY') {
if (!empty($cfg['new_name'])) {
$st .= "RENAME COLUMN ";
$st .= $this->escape($cfg['col_name']) . ' TO ' . $this->escape($cfg['new_name']);
} else {
$st .= "ALTER COLUMN ";
$st .= $this->escape($cfg['col_name']) . ' TYPE ';
$st .= $this->getColumnDefinitionStatement($cfg['col_name'], $cfg, false, true);
}
}
elseif ($alter_type === 'DROP') {
$st .= "DROP COLUMN " . $this->escape($cfg['col_name']);
}
else {
$st .= $alter_type . ' COLUMN ' . $this->getColumnDefinitionStatement($cfg['col_name'], $cfg);
}
return $st;
}
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions