portal.mkgtu.ru/common/db/views/_addForeignKeys.php

20 lines
584 B
PHP
Raw Normal View History

2024-03-28 09:51:45 +03:00
<?php foreach ($foreignKeys as $column => $fkData): ?>
// creates index for column `<?= $column ?>`
$this->createIndex(
'<?= $fkData['idx'] ?>',
'<?= $table ?>',
'<?= $column ?>'
);
// add foreign key for table `<?= $fkData['relatedTable'] ?>`
$this->addForeignKey(
'<?= $fkData['fk'] ?>',
'<?= $table ?>',
'<?= $column ?>',
'<?= $fkData['relatedTable'] ?>',
'<?= $fkData['relatedColumn'] ?>',
'CASCADE'
);
<?php endforeach;