W
W
WebDev2015-09-22 15:16:20
Doctrine ORM
WebDev, 2015-09-22 15:16:20

Double query in doctrine + phalcon?

Hello, it was required for the project to use phalcon framework and doctrine. I didn’t work much with either one, so I decided to take a ready-made skeleton application. Googled and found https://github.com/imuneer/phalcon-doctrine. I started it, everything is fine, but in the controller there is an action index with the following code:

$em = $this->di['entityManager'];
    	$c = new Customer();
    	$c->setLabel("Customer - " . rand());

    	$em->persist($c);
    	$em->flush();

    	$customers = $em->getRepository('Models\Customer')->findAll();
    	$this->view->customers = $customers;

And when run, this code creates 2 records in the db. I began to pick, created an addAction () action in the same controller and duplicated the code there, 2 entries were also created. Then I removed the adding code from indexAction and everything started working fine. addAction() adds one entry, created another action for the test, everything is fine there too, but if you add the add code to the index, then the entries are duplicated. What can be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
My joy, 2016-01-23
@t-alexashka

I have suspicions that the jamb in the routing, tk. in the project, I did not find an explicit declaration of it, which means that the default route is used, and perhaps the index is called 1 time, and the 2nd time is the desired action.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question