Doctrine ORM: drop all tables without dropping database?

Yes, surely you can use doctrine only for some tables(not all). And it won't drop all the other tables. , unless you manually run $manager->dropDatabases() This is how you can start using Doctine for your new tables: Setup DB Connection Setup Doctrine's files/directory structure Use Command Line Interface in order to automatically generate all Doctrine models(and schema) based on DB tables(you can delete unncessesary models manually).

Yes, surely you can use doctrine only for some tables(not all). And it won't drop all the other tables. , unless you manually run $manager->dropDatabases(); This is how you can start using Doctine for your new tables: Setup DB Connection Setup Doctrine's files/directory structure Use Command Line Interface in order to automatically generate all Doctrine models(and schema) based on DB tables(you can delete unncessesary models manually).

The problem is that there's no command line option to build all (re)load without dropping existing database – gpilotino Oct 18 '09 at 23:18 1 @gpilotino: Don't Do That Then! Just build-schema, build-model etc. Or write a task to do what you need to do. – dland Oct 21 '09 at 13:01 ok but still you cannot do this with command line (dropping all tables).

Finally I had to write some code to cycle on them. – gpilotino Oct 22 '09 at 21:37.

You can find a task I use to truncate all tables from a db at this gist: https://gist.github. Com/1154458 The core code is: $this->dbh = $connection->getDbh(); $this->dbh->query(sprintf('SET FOREIGN_KEY_CHECKS = 0;')); $tables = $connection->import->listTables(); foreach ($tables as $table) { $this->dbh->query(sprintf('TRUNCATE TABLE %s', $tableName)); } $this->dbh->query(sprintf('SET FOREIGN_KEY_CHECKS = 1;')).

Gpilotino Yes, I'm having a similar problem. There seems to be NO WAY to drop and rebuild the database from within PHPUnit, (The future of Symfony testing). Maybe it's possible in 'lime',I don't know.So, I am having to write a reverse ->save() function that backs all the data out of the database, and then resets all the sequences so that I can do automated testing.

For those who don't want to follow in my frustration I tried both: 1) using a Task from inside of symfony: $optionsArray=array(); $argumentsArray=array(); $optionsArray="--all"; $optionsArray="--and-load"; $optionsArray="--no-confirmation"; $task = new sfDoctrineBuildTask($configuration->getEventDispatcher(), new sfFormatter()); $task->run($argumentsArray, $optionsArray); 2)Executing it from outside of symfony while inside of PHP: Doctrine_Manager::getInstance()->getCurrentConnection()->close(); exec('. /symfony doctrine:build --all --and-load --no-confirmation'); The reason that I closed the connection is that Postgres, MDBOC (my db of choice) will not drop a database that has a connection. Probably is STILL some kind of problem.

I tell ya, it's NEVER as easy as the simple tutorials show. And it's even WORSE with microslop products.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions