doctrine-orm

Infinite loop in Doctrine event listener when trying to save additional entity

主宰稳场 提交于 2020-01-05 03:09:32
问题 I want that every time a new Distance entity (from Place_A to Place_B) is saved, the reverse distance (from Place_B to Place_A) gets inserted too into the DB. My problem is the following listener loops infinitely (hence the counter): class Listener { public $count; public function prePersist(LifecycleEventArgs $eventArgs) { if ($this->count > 5) { die(); } $entity = $eventArgs->getEntity(); if ($entity instanceof Distance) { // $this->created = microtime(true) in Distance's constructor echo

How to export contact to CSV with my service?

穿精又带淫゛_ 提交于 2020-01-04 16:01:02
问题 I have a symfony2 service to export a database into a CSV file making it availaible to the. I got this error: The controller must return a response ( null given ) . Did you forget to add a return statement somewhere in your controller? I do not understand why. Could you enlighten me on this? My code : namespace Rac\CaraBundle\Manager; /* Imports */ use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\Validator\ValidatorInterface; use Symfony\Component\EventDispatcher

Many to Many, One to Many or Many to One

笑着哭i 提交于 2020-01-04 14:19:47
问题 I am trying to get my head around Doctrine 2 ORM relationships, I thought I had the hang of it but after reading a few symfony cookbook entries, I suspect I am actually a little confused. I currently have a system where a template can contain multiple modules (including more than one of each type) and multiple templates can use the same module. I thought that this would warrant a ManyToMany relationship and indeed looking at my table, it seems to work quite well. However I realised as I was

Doctrine2 inverse persistance not working in nested forms

瘦欲@ 提交于 2020-01-04 09:18:15
问题 I am creating a MotorsAds entity to which I am linking with MotorsAdsFile entity. For each MotorsAds , we could attach many MotorsAdsFile . My objective is creating a form for MotorsAds which allows adding MotorsAdsFile just through a click on a button. Here, I am trying to implement the embeded forms. My problem is that I got that error: An exception occurred while executing 'INSERT INTO MotorsAdsFile (filename, motors_id) VALUES (?, ?)' with params ["5493b613839d7_2012-07-02 22.06.00.jpg",

Injectiong or accessing service container within an entity object

蓝咒 提交于 2020-01-04 09:17:11
问题 I want to access service container withing the entity below but how? Checked this but I got lost when I was reading listeners; Get service container from entity in symfony controller public function indexAction() { $orders = $this->getDoctrine()->getManager()->getRepository('MyAdminBundle:Orders')->findAll(); ..... } entity namespace My\AdminBundle\Entity; class Orders { private $container; public function __constructor() { $this->container = ?????? } public function getCurrency() { return

Symfony2 doctrine:generate:entities chmod operation not permitted

橙三吉。 提交于 2020-01-04 07:09:28
问题 Recently upgraded from 2.3.1 to 2.8.7 on a dev machine. All has been going fine until I needed to create a new table. Managed to generate the yml fine via doctrine:mapping:convert When I come to create the getters and setters via doctrine:generate:entities I get this: [Symfony\Component\Debug\Exception\ContextErrorException] Warning: chmod(): Operation not permitted And nothing else. Which isn't very helpful. Is it a chmod which I need to add an @ to somewhere? I am executing the command as

Symfony connect to database: ODBC connection on PHP7

纵然是瞬间 提交于 2020-01-04 06:15:07
问题 Just use the Driver of Microsoft Github repo - it was already working with the beta and now they stabilized it - I forgot to "answer" the question here by myself - sorry for that delay. Link: Azure MSSQL How is it possible to connect from symfony2.8 on PHP7 to a MSSQL server using ODBC connection? Can't find anything in the net, except for some legacy stuff. What needs to be changed / done? I know that Symfony offers odbc, can I still use doctrine as mapper when connecting through odbc? 回答1:

How to generate Doctrine entities From Database and Use PSR-4 Autoloading?

家住魔仙堡 提交于 2020-01-04 05:43:25
问题 Using Doctrine 2.5 with PSR-4 autoloading and converting an already designed database schema to entity classes (annotations). The problem is getting the exported files in the correct directory structure. composer.json { "autoload": { "psr-4": { "Application\\": "src/" } }, "require": { "doctrine/orm": "^2.5" } } orm:convert-mapping vendor/bin/doctrine orm:convert-mapping \ --namespace='Application\Entity\' \ --force \ --from-database \ annotation \ src/ Running this command will add an

MYSQL sorting with doctrine

有些话、适合烂在心里 提交于 2020-01-04 05:42:30
问题 as described in this question and as its answered with "Not possible" i opened a new question so my problem goes like this : I have a table (ServiceProvider Table) each service provider have many offers (Offer table) with a OneToMany relation and each Offer have a master service (Service table) with a ManyToOne relation. What i am trying to do is to get all the service providers and their offers in an order related to serviceProvider.points and then serviceProvider.name and each service

symfony2 doctrine onetoone complete example

六月ゝ 毕业季﹏ 提交于 2020-01-04 04:43:32
问题 i try make onetoone relation from example - http://docs.doctrine-project.org/en/latest/tutorials/composite-primary-keys.html#use-case-2-simple-derived-identity this is second try , first is here symfony 2 doctrine relation onetoone Adres <?php /** * Created by PhpStorm. * User: grek * Date: 18.12.13 * Time: 16:33 */ namespace Miejsce\ObiektyBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class Adres { /** * @var integer * @ORM\Column(type="integer") * @ORM\Id * @ORM