doctrine-orm

Symfony2: does fetch=“EAGER” create a join?

寵の児 提交于 2020-01-03 13:20:26
问题 I have this mapped property inside my product entity: /** * @ORM\ManyToMany(targetEntity="Group", mappedBy="products", indexBy="id", fetch="EAGER") * */ protected $groups; I wonder, my understanding for fetch="EAGER" is that it should get the groups once the product is selected, this is what happens but it uses 2 queries whenever i do something like findBy() one query to get the product and another one to get the groups . Is there anyway to make findBy() or other helper methods get the

persist new entity onFlush

浪子不回头ぞ 提交于 2020-01-03 11:29:34
问题 I try to user the onFlush Event in Doctrine to persist a new entity, but it leads to an infinite loop when trying to persist. Here is what I do in the Listener: $countusers = $em->getRepository('DankeForumBundle:NotificationUser')->countNotificationsByDeal($entity); if ($countusers > 0) { $notification = new NotificationAction(); $notification->setDeal($entity); $notification->setDatepost(new \DateTime()); $notification->setNotificationtype(NotificationAction::TYPE_TOP_DEAL); // $em is set to

The Doctrine repository “Doctrine\ORM\EntityRepository” must implement UserProviderInterface in symfony2

只愿长相守 提交于 2020-01-03 06:30:53
问题 I am getting above error when login. With property option in security.yml it is working. I have added the @ORM\Entity(repositoryClass="versionR\userBundle\Entity\UserRepository") line on my entity class, dobule checked path, cleared cache but no luck. User entity class <?php namespace versionR\userBundle\Entity; use Doctrine\ORM\Mapping as ORM; //use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\User\UserInterface; /** * User * * @ORM\Table(name="user") * @ORM

Silex and Doctrine - ORMException: Unknown Entity namespace alias [semi fixed]

大兔子大兔子 提交于 2020-01-03 06:07:21
问题 I'm trying to use the Doctrine components in my app built using silex. I was able to get it to work - well almost. I have my "User" entity and the corresponding repository When doing $app['em']->getRepository('Foo\Entity\User')->findAll() works as expected, however when trying to make a custom query $this->getEntityManager() ->createQuery( 'SELECT u FROM Foo:User u WHERE c.id = :x' ) ->setParameter('x',$in) ->getResult(); I get this exception ORMException: Unknown Entity namespace alias 'Foo'

Silex and Doctrine - ORMException: Unknown Entity namespace alias [semi fixed]

雨燕双飞 提交于 2020-01-03 06:06:48
问题 I'm trying to use the Doctrine components in my app built using silex. I was able to get it to work - well almost. I have my "User" entity and the corresponding repository When doing $app['em']->getRepository('Foo\Entity\User')->findAll() works as expected, however when trying to make a custom query $this->getEntityManager() ->createQuery( 'SELECT u FROM Foo:User u WHERE c.id = :x' ) ->setParameter('x',$in) ->getResult(); I get this exception ORMException: Unknown Entity namespace alias 'Foo'

Type error: Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be of the type array, object given

*爱你&永不变心* 提交于 2020-01-03 06:01:14
问题 Actually... more or less I know where is my problem. I'm receiving this error in a particular controller where I try to persist($object) ... Actually I'm developing a webapp for me to have a register to all my books I'm reading.. and I use Google Books API for that. So, I have the next Entities: Admin Users Books Categories I was thinking about the db and I wanted a table with user_id, book_id so I decided to do a ManyToMany but, I don't know if this is the way.. or not. (Because my familiars

SonataAdminBundle file upload: Error

一笑奈何 提交于 2020-01-03 05:53:11
问题 I'm a student actually working on my own Symfony2 project and it's few days now I can't find a solution to my problem. UPDATE: 03.09.2013 I have the current version of symfony and of the sonata admin bundle and need a form in my admin with multiple image uploads. The following code I present is based on this installation documentation: http://sonata-project.org/bundles/admin/master/doc/reference/recipe_file_uploads.html In my case I have an entity Projects (Pf\Bundle\BlogBundle\Entity

Get Doctrine or pass in service without using __construct - Symfony2

痞子三分冷 提交于 2020-01-03 04:52:22
问题 I'm trying to extend a class, but I have this problem: (1) I need to conduct a simple database query, but if I pass in @doctrine.orm.entity_manager in services.yml I then need to pass a load of other values in and call parent::__construct (for the parent class) and I just can't get it working (another question exists for that but no luck). (2) If I don't create a __construct in my new extended class then it works but I can't get access to conduct the DB query. Is there a way of getting access

Assign many items to one category - OneToMany Relation

送分小仙女□ 提交于 2020-01-03 03:18:24
问题 I want to assign many items to one category. I'm using Symfony 2.6.7. I'm not at the owning side here. If I open this URI: /category/2/assign [x] Item 1 [x] Item 2 (Save Button) I have the possibility to chose many items with checkboxes. This is my db table "Item", where I want to connect the both: id | category_id It is an OneToMany relation, where One = Category and Many = Items. How can I assign the both here? It is already working, when I edit one item and than select a category to this

How to pass parameters to a custom Doctrine type in Symfony4

人走茶凉 提交于 2020-01-03 02:21:05
问题 I have developed a new Doctrine type to encrypt strings. <?php namespace App\Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\StringType; use App\Security\Encoder\OpenSslEncoder; class EncryptedStringType extends StringType { const MTYPE = 'encrypted_string'; private $cypherMethod; private $iv; private $privateKey; public function convertToPHPValue($value, AbstractPlatform $platform) { $openSslEncoder = new OpenSslEncoder($this->cypherMethod, $this-