Hi there,
I would like to add a column to a table in a connected MySQL database through Kirby.
This is where I’m at:
I connected to the database in config.php:
'db' => [
'host' => 'xxx',
'database' => 'xxx',
'user' => 'xxx',
'password' => 'xxx',
],
In the snippet, through which the column is supposed to be added:
I select an instance of the database.
I validate if the table exists.
I validate if the column already exists in the table.
$database = Database::instance();
$tableName = 'my_table';
if( $database->validateTable($tableName) ){
$columnName = 'new_column';
if( $database->validateColumn($tableName, $columnName) ){
// column exists
} else {
// create column
$props = array( 'type' => 'text' );
// what's next?
}
}
I would need something like:
$table->createColum($columnName,$props);
Or some sql query maybe