Dzisiaj napotkałem się na dziwny błąd. Mianowicie mam encje: User oraz AbstractUserAccount
Encja User:
/** * Class User * @package Crmatic\Bundle\SecurityBundle\Entity * * @ORM\Entity(repositoryClass="Crmatic\Bundle\SecurityBundle\Repository\UserRepository") * @ORM\Table(name="users") */ class User extends AbstractEntity implements UserInterface { //... /** * @ORM\OneToMany(targetEntity="Crmatic\Bundle\SecurityBundle\Entity\AbstractUserAccount", mappedBy="user") * * @var AbstractUserAccount[] */ protected $userAccounts; //... }
Encja AbstractUserAccount:
/** * Class AbstractUserAccount * @package Crmatic\Bundle\SecurityBundle\Entity * * @ORM\Entity(repositoryClass="Crmatic\Bundle\SecurityBundle\Repository\UserAccountRepository") * @ORM\Table(name="users_accounts", * uniqueConstraints={@ORM\UniqueConstraint( * name="unique_user_accounts", * columns={"account_id", "user_id", "role_id"} * )} * ) * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorMap({ * "client" = "Crmatic\Bundle\SecurityBundle\Entity\UserAccount\ClientAccount", * "owner" = "Crmatic\Bundle\SecurityBundle\Entity\UserAccount\OwnerAccount" * }) */ class AbstractUserAccount { /** * @ORM\ManyToOne(targetEntity="Crmatic\Bundle\SecurityBundle\Entity\User", inversedBy="userAccounts") * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false, onDelete="CASCADE") * * @var User */ protected $user; /** * @ORM\ManyToOne(targetEntity="Crmatic\Bundle\SecurityBundle\Entity\Account") * @ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false, onDelete="CASCADE") * * @var Account */ protected $account; }
W bazie mam 2 rekordy:
| id | user_id | account_id | discr
| 4 | 1 | 1 | owner
| 5 | 1 | 1 | client
Użytkownik po zalogowaniu ma możliwość wybrania konta. Po zalogowaniu użytkownik jest zapisywany do sesji. Gdy przechodzę na stronę z wyborem konta nie wiem czemu dla rekordu z id 4 z tabeli users_accounts w polu $user jest wartość 3 (integer). Ogólnie nie mam nigdzie w bazie rekordu z id 3. Skąd ta wartość się bierze ?
Pozdrawiam.