Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6849979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:04:03+00:00 2026-05-27T01:04:03+00:00

How do I remove entities in Doctrine 2? I want to know how to

  • 0

How do I remove entities in Doctrine 2? I want to know how to do this through the command line and with PHP. Thanks!

Edit:
I’m not sure if I’m asking this question right (I’m new to Doctrine). I want to leave the Entity file in the directory, but I want to delete its table from the database. This stems from Zend based modular architecture where modules can be installed/uninstalled without the module directory being removed. If a module is uninstalled, I want its entities removed. The opposite is also true.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:04:04+00:00Added an answer on May 27, 2026 at 1:04 am

    I did some looking into Doctrine’s API and eventually figured it out:

    $classes = array();
    $entityManager = ...
    $classes[] = $entityManager->getClassMetadata('Entities\MyEntity1');
    $classes[] = $entityManager->getClassMetadata('Entities\MyEntity2');
    $classes[] = $entityManager->getClassMetadata('Entities\MyEntity3');
    $classes[] = $entityManager->getClassMetadata('Entities\MyEntity4');
    
    //Doctrine Schema Tool
    $st = new Doctrine\ORM\Tools\SchemaTool( $entityManager );
    $st->dropSchema($classes);
    

    This will remove the tables associated with Entities\MyEntity1, 2, 3 and 4 from the database.

    Also, using the exact same code above except the last line, the following methods are useful:

    $st->createSchema($classes);
    

    AND

    $st->updateSchema($classes);
    

    You can find all the info in Doctrine’s documentation:

    http://www.doctrine-project.org/projects/orm/2.0/api

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does this preg_replace to remove HTML entities not work? // Remove all HTML
This question is similar to the Remove html character entities in a string question
Remove first comma on each line in a file. I presume sed is needed.
remove() method without any argument removes all documents inside the collection. $this->db->$collection->remove(); But how
I try to remove entities from a collection but it doesn't work. I think
I know how to remove an entry, 'key' from my dictionary d , safely.
The entities and mappings I'm talking about in this question can be found here
I am trying to store entities in MyBundle/OtherNamespacePart/Entity directory. If I run doctrine:schema:create ,
i am getting an error, when applying php app/console doctrine:schema:update --force i get a
How can I remove all entities or reset the local datastore on my dev_appserver?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.