mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
I can't insert data to database #5985
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Jun 11, 2018).
Originally assigned to: @Ocramius on GitHub.
version 2.6.1
first time I'm using doctrine and there is a problem about insterting data. I created entity class then created table with console command. But it comes to insert something, I can't insert anything..
it says;
I googled it and all solutions about symfony configuration but I don't use symfony..
and bootstrap class
@Ocramius commented on GitHub (Jun 11, 2018):
What is the full stack trace for that error?
@ghost commented on GitHub (Jun 13, 2018):
@Ocramius nothing actually.. I tried that and I got nothing..
@Ocramius commented on GitHub (Jun 13, 2018):
You don't need to add any code - just display the full exception as it is rendered when having
ini_set('display_errors', '1');@ghost commented on GitHub (Jun 13, 2018):
@Ocramius I'm working with localhost, I'm already displaying errors but there is no error. I check with different methods to get any error like php-doctrine error, or pdo error but I got nothing.
@Ocramius commented on GitHub (Jun 14, 2018):
Where did you get this one from?
@ghost commented on GitHub (Jun 14, 2018):
@Ocramius I passed metadata driver, and still it doesn't persist without any error
@Ocramius commented on GitHub (Jun 14, 2018):
@hsntngr55 hmm, your bootstrapper is creating a new
EntityManagerevery time, so it's obviously empty when attempting to flush it.Closing as
resolvedhere :-)@ghost commented on GitHub (Jun 14, 2018):
so, if I use as static, it will work ?
@Ocramius commented on GitHub (Jun 14, 2018):
Please don't do that: use dependency injection instead :-)
@ghost commented on GitHub (Jun 14, 2018):
@Ocramius well, it works like a charm, thank you a lot :) but I didin't get it logic behind this. why class is empty ? I'm sending a $post entity as a parameter ?
@Ocramius commented on GitHub (Jun 14, 2018):
@hsntngr55 in your example above:
$orm->conn()leads to a newEntityManagerbeing produced at each call, which means that the third line is calling->flush()on an emptyEntityManager