Category : doctrine-orm

I have an entity SiteProject, SiteProjectPhoto and CommonPhoto. I try to check only one "main_photo" by project. so when I update an object SiteProjetPhoto, I check all other SiteProjectPhoto to update the "main" params of CommonPhoto. The SiteProjectPhoto is well modified but not the other one (ie CommonPhoto "main" attribute is not modified). Here is ..

Read more

Is there a way to write DQL queries without specifying the fully qualified name of the class? Is there a way to create the following query: return $this->getEntityManager()->createQuery( ‘SELECT i FROM CompanyAccountingBundleEntityInvoice i WHERE i.id = :id’ )->setParameter(‘id’, 1) ->getResult(); Like this : use CompanyAccountingBundleEntityInvoice; …. return $this->getEntityManager()->createQuery( ‘SELECT i FROM Invoice i WHERE i.id ..

Read more

I have problem with my entity relation. My relation looks like this: /** * @ORMEntity() * @ORMTable(name="custom_menu_item_translation") */ class MenuItemTranslation { use TraitsUniqueIdTrait; /** * @ORMManyToOne(targetEntity="MenuItem", inversedBy="translations") * @ORMJoinColumn(name="menu_id", referencedColumnName="id", nullable=false, onDelete="CASCADE") */ protected MenuItem $menu; /** * @return MenuItem */ public function getMenu(): MenuItem { return $this->menu; } /** * @param MenuItem $menu * ..

Read more

I have problem with my OneToMany relation. I got 2 entity MenuItem and MenuItemTranslation. Relation looks like this: MenuItemTranslation entity /** * @ORMEntity() * @ORMTable(name="custom_menu_item_translation") */ class MenuItemTranslation { use TraitsUniqueIdTrait; /** * @ORMManyToOne(targetEntity="MenuItem", inversedBy="translations") * @ORMJoinColumn(name="menu_id", referencedColumnName="id", nullable=false, onDelete="CASCADE") */ protected MenuItem $menu; /** * @return MenuItem */ public function getMenu(): MenuItem { return ..

Read more

im working on a symfony/doctrine/Api-platform project and would like to add a @ORMDiscriminatorMap to my class, and would like to reference a class that is not in the namespace. The documentation only says: The names of the classes in the discriminator map do not need to be fully qualified if the classes are contained in ..

Read more

I created php project using composter creating project And im trying to connect to my database like this: <?php require_once __DIR__ . ‘/../../vendor/autoload.php’; use DoctrineORMORMException; use DoctrineORMToolsSetup; use DoctrineORMEntityManager; try { $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . ‘/src’)); $conn = array( ‘dbname’ => ‘lab7’, ‘user’ => ‘root’, ‘password’ => ”, ‘host’ => ‘localhost’, ‘driver’ => ‘pdo_mysql’, ‘charset’ ..

Read more