php - How to create table with raw SQL in symfony controller and get a response -


i have controller create table 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 cannot seem figure out how response know if executed successfully. ideas?

cerad correct. errorcode , check if '0000'. i'm using mysql , '0000' errorcode if ran successfully.

... $statement->execute();  var_dump( $statement->errorcode() );   // error code. 

i think should work you.

for reference got doctrine api documentation , tried out. here link reference:

http://www.doctrine-project.org/api/dbal/2.4/class-doctrine.dbal.driver.statement.html


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -