1. Go to this page and download the library: Download illusiard/yii2-db-toolkit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
illusiard / yii2-db-toolkit example snippets
use illusiard\dbtoolkit\components\CreateTable;
final class m240101_000001_create_post_table extends CreateTable
{
public function getTableName(): string
{
return 'post';
}
public function getColumns(): array
{
return [
'title' => $this->string(255)->notNull()->comment('Заголовок'),
'body' => $this->text()->null()->comment('Текст'),
];
}
public function getIndexes(): array
{
return [
['title'],
];
}
public function getForeignKeys(): array
{
return [
'user_id' => ['user', 'id', 'onDelete' => 'RESTRICT', 'onUpdate' => 'CASCADE'],
];
}
}
use illusiard\dbtoolkit\components\BaseDictionaryCreateTableMigration;
final class m240101_000002_create_country_dict extends BaseDictionaryCreateTableMigration
{
public function getTableName(): string
{
return 'dict_country';
}
}
use illusiard\dbtoolkit\schema\SchemaIntrospector;
$introspector = new SchemaIntrospector($db);
$schema = $introspector->introspectSchema();
$table = $introspector->introspectTable('post');