Reputation: 256
I have a controller where I create a table with doctrine raw sql:
$sql = 'CREATE TABLE IF NOT EXISTS testTable
(id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))
DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB';
$em = $this->getDoctrine()->getManager();
$statement = $em->getConnection()->prepare($sql);
$statement->execute();
Yet I cannot seem to figure out how to get a response to know if it executed successfully. Any ideas?
Upvotes: 1
Views: 780
Reputation: 7764
Cerad is correct. Get the errorCode
and check if it is '0000'. I'm using MySQL and I get '0000' as an errorCode if it ran successfully.
...
$statement->execute();
var_dump( $statement->errorCode() ); // Get the error code.
I think that should work for you.
For reference I got that from the Doctrine API documentation and I tried it out. Here is the link for reference:
http://www.doctrine-project.org/api/dbal/2.4/class-Doctrine.DBAL.Driver.Statement.html
Upvotes: 2
Reputation: 91
Response should be in your "statement" variable, add a: var_dump($statement);
and see.
Upvotes: 1