I'm trying to create a importing system by using Symfony2
. A new table must be automatically created when a user imports a new dataset.
For example, if the user imports 3 datasets, we will have DataA
, DataB
, and DataC
tables.
I have been searching on "How to create and insert data in DQL", However, it's written that DQL
doesn't have Create
and Insert
queries - Only Select
, Update
, and Delete
are allowed.
So, what is the good practice to achieve this approach? I have only an idea in my head which is to create a plain SQL query
, I don't know if this is a good way in Symfony2
and Doctrine
.
I think that it should be better if we could achieve this by using Object Relation Mapping, ORM
. Is it possible?
Try to use next code in controller:
$conn = $this->get('database_connection');
$sql = "CREATE TABLE __tablename__";
$stmt = $conn->prepare($sql);
$stmt->execute();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.