Prasad
Prasad

Reputation: 1820

Symfony: Executing custom SQL in a task

I basically want to create a custom doctrine task that truncates data in all the tables. I was trying this approach by getting the active Doctrine connection, and executing custom SQL statements that truncate the tables. After I finally got the connection, I got a fatal error stating PDO::execute() is an undefined method. Do I need to include a file?

Code:

$connection = $databaseManager->getDatabase('doctrine');
$st = $connection->execute("...............");

Thanks

Upvotes: 1

Views: 889

Answers (2)

Maerlyn
Maerlyn

Reputation: 34105

Guess you were looking for exec.

Upvotes: 2

Prasad
Prasad

Reputation: 1820

Alternative is to the drop the DB each time:

> symfony doctrine:build-sql
> symfony doctrine:drop-db
> symfony doctrine:insert-sql

Source: How to make 'symfony doctrine:build-sql' task generate 'DROP' statments?

Upvotes: 0

Related Questions