Deleting table using Doctrine2 and Symfony2

前端 未结 4 1836
悲哀的现实
悲哀的现实 2021-01-05 19:04

How can I delete table using Doctrine2 and Symfony2? I\'ve generated entities and updated schema, now I want to delete this structure.

4条回答
  •  北海茫月
    2021-01-05 19:51

    You can do a raw sql.

    For example in a Symfony2 controller:

    $em = $this->getDoctrine()->getManager();
    $sql = 'DROP TABLE hereYourTableName;';
    $connection = $em->getConnection();
    $stmt = $connection->prepare($sql);
    $stmt->execute();
    $stmt->closeCursor();
    

提交回复
热议问题