method getAlterColumn documentation in bbn\Db\Languages\Mysql

Return a string for alter column statement.

Example

$cfg = [ 'col_name' => 'id', 'type' => 'binary', 'maxlength' => 32 ]; X::dump($db->getAlterColumn('users', $cfg); // (string) ALTER TABLE `users` ADD `id` binary(32) NOT NULL 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' && !empty($cfg['new_name'])) { $st .= "CHANGE COLUMN "; $st .= $this->escape($cfg['col_name']) . ' ' . $this->escape($cfg['new_name']) . ' '; $st .= $this->getColumnDefinitionStatement($cfg['col_name'], $cfg, false); } elseif ($alter_type === 'DROP') { $st .= "DROP COLUMN " . $this->escape($cfg['col_name']); } else { $st .= $alter_type . ' ' . $this->getColumnDefinitionStatement($cfg['col_name'], $cfg); } if ($alter_type !== 'DROP') { if (!empty($cfg['after']) && is_string($cfg['after'])) { $st .= " AFTER " . $this->escape($cfg['after']); } } return $st; }

Return a string for alter column statement. 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.