2

In my symfony2 application there is a need to create a table on the basis of user selection. if user selects yes then a new table will be create into database.

I am trying to create table query into symfony2 controller but getting error message

Error: Expected SELECT, UPDATE or DELETE, got 'CREATE' 

Is it any way to run create table query into controller.

2
  • it's a very bad practice why you wanna do that in the controller you can just run this command : php app/console generate:doctrine:entity Commented Jan 14, 2016 at 11:58
  • @elkorchianas , I just update my question. Commented Jan 14, 2016 at 12:10

1 Answer 1

0

I know that it's BAD practice, but it just a single working way that i know.

$em = $this->getDoctrine()->getManager();
$em->getConnection()->exec('create table tmp (id int)');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.