A
A
ADA M2019-11-14 12:57:57
Doctrine ORM
ADA M, 2019-11-14 12:57:57

How to completely copy a table structure through Doctrine?

Please tell me how to completely copy a table through Doctrine, including indexes and foreign keys (ForeignKeyConstraint).
For example, this code will return an SQL query only to create a table with indexes, but without foreign keys:

$tool = new SchemaTool($this->em);
$metadata = $this->em->getClassMetadata(<Любая сущность, имеющая внешние ключи>::class);
$tool->getCreateSchemaSql([$metadata]); // вернет массив из 1го элемента (но по идее должен вернуть больше элементов с SQL-запросами на создание внешних ключей)

There is also a native SQL command: Which also does not copy foreign keys. Of course, you can choose from the scheme, but the solution through Doctrine is of interest. CREATE TABLE new_tbl LIKE orig_tbl;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nujabes37, 2019-11-14
@Nujabes37

Here you can find the answer. Via Doctrine \_(-_-)_/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question