Giter Site home page Giter Site logo

Comments (12)

roukmoute avatar roukmoute commented on June 11, 2024

Hi,

I don't think your numbers of lines are correct (https://github.com/roukmoute/DoctrinePrefixBundle/blob/master/src/Subscriber/PrefixSubscriber.php#L45-L47)

You're problem is interesting, I'll see if I can get the same thing.

Why do not you propose a correction?

from doctrineprefixbundle.

jngermon avatar jngermon commented on June 11, 2024

Hi,

The correct lines numbers are 53/55.... sorry.

My solution is to delete there lines, but I think you wrote there for a reason. This reason is still right ?

from doctrineprefixbundle.

roukmoute avatar roukmoute commented on June 11, 2024

I cant' work now on your problem.
I check later.
Could you give me your concrete example please ?

I fix it quickly

from doctrineprefixbundle.

jngermon avatar jngermon commented on June 11, 2024

Mother class

<?php

namespace AppBundle\Entity\Selection;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 * @ORM\Table(name="selection_selection")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 * @ORM\DiscriminatorMap({
 *       "dynamic_book" = "SelectionDynamicBook",
 *   })
 */
class Selection
{
    /**
     * @var integer
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
}

Daugther class

<?php
namespace AppBundle\Entity\Selection;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use AppBundle\Entity\Ebook\Genre;

/**
 * @ORM\Entity
 */
class SelectionDynamicBook extends Selection
{
    /**
     * @var \Doctrine\Common\Collections\ArrayCollection<Genre>
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Ebook\Genre", inversedBy="selections")
     * @ORM\JoinTable(
     *     name="selection_book_genre",
     *     joinColumns={@ORM\JoinColumn(name="selection_id", referencedColumnName="id")},
     *     inverseJoinColumns={@ORM\JoinColumn(name="genre_id", referencedColumnName="id")}
     * )
     */
    protected $genres;

    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();

        $this->genres = new ArrayCollection();
    }

    /**
     * Add genre
     *
     * @param Genre $genre
     * @return SelectionDynamicBook
     */
    public function addGenre(Genre $genre)
    {
        if (!$this->genres->contains($genre)) {
            $this->genres[] = $genre;
        }

        return $this;
    }

    /**
     * Remove genre
     *
     * @param Genre $genre
     */
    public function removeGenre(Genre $genre)
    {
        $this->genres->removeElement($genre);
    }

    /**
     * Get genres
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getGenres()
    {
        return $this->genres;
    }
}

After my schema's update I have 2 tables :

  • One with good prefix : prefix_selection_selection who contains all fields of Mother and Daugther class
  • One without prefix : selection_book_genre who represent the junction between the daughter (SelectionDynamiqueBook) and the object Genre

If I delete the lines 53/55 in your listener the second table as got a good prefixed table name (prefix_selection_book_genre).

from doctrineprefixbundle.

roukmoute avatar roukmoute commented on June 11, 2024

Ok thanks for your help.
I'm on it as soon as possible !

from doctrineprefixbundle.

roukmoute avatar roukmoute commented on June 11, 2024

Hi,

I've tried to reproduce your problem, but I can't.
My prefix has called " roukmoute"

There is an small example with ManyToMany Unidirectional: https://gist.github.com/roukmoute/93d683735cd19a227c52
And this is a dump-sql : https://asciinema.org/a/83aax3mnh6noxjtxb8nxn8umg

All tables have roukmoute

from doctrineprefixbundle.

jngermon avatar jngermon commented on June 11, 2024

Hi,

You've forget to add inheritance SINGLE_TABLE !
The mother have to get

 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 * @ORM\DiscriminatorMap({
 *       "key" = "Daugther",
 *   })

And is Daughter who have to get ManyToManty association with an other object.

It's the generated table for this association who has not good prefix.

I have send you an example in roukmoute / Entity.php

Thank

from doctrineprefixbundle.

roukmoute avatar roukmoute commented on June 11, 2024

Yep I've tried but your example need another tables, so I've tried just to apply about your first message.
OK I will try with "SINGLE_TABLE"

from doctrineprefixbundle.

roukmoute avatar roukmoute commented on June 11, 2024

OK I've the same thing as you :

from doctrineprefixbundle.

jngermon avatar jngermon commented on June 11, 2024

You can see that your table 'daugthers_mothers' haven't got prefix ?

I don't know what this table is call 'daughters_mothers' because it's not write in your entity.php but You can see the problem in the assciinema

from doctrineprefixbundle.

jngermon avatar jngermon commented on June 11, 2024

Thanks !!

After update it works perfectly !

from doctrineprefixbundle.

roukmoute avatar roukmoute commented on June 11, 2024

👍

from doctrineprefixbundle.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.