kdyby doctrine nenacte spracne entitu z db
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- jarda256
- Člen | 130
Ahoj, mám takový problém, když si zavolám
$this->em->getRepository(Event::class)->find(3)
tak bych
měl dostat vytaženou z db entitu event s id 3. Což dostanu, ale některé
proměnné jsou NULL i když v db jsou vyplněné. Respektive vše je
vyplněno, ale i tak dostanu NULL. Nevíte prosím někdo čím by to
mohlo být?
App\Model\Entities\Event #8de8
sites private => Doctrine\ORM\PersistentCollection #eb61
optItems private => Doctrine\ORM\PersistentCollection #a32b
visible protected => NULL
name protected => "Nazev" (16)
ename protected => "EN nazev" (13)
regInt1 protected => NULL
regInt2 protected => NULL
regInt3 protected => NULL
regInt4 protected => NULL
regInt5 protected => NULL
date protected => NULL
approve protected => NULL
note protected => NULL
registrations private => Doctrine\ORM\PersistentCollection #d935
id private => 3
- igor.pocta
- Člen | 100
Zkusil jsi smazat cache? Schema tool update? Pokud ano, vlož sem soubor té entity, kde ji máš nastavenou (anotace, yaml, xml)
- jarda256
- Člen | 130
@igor.pocta
<?php
namespace App\Model\Entities;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Kdyby\Doctrine\Entities;
use Nette\Utils\Arrays;
/**
* @ORM\Entity
* @ORM\Table(name="events")
*/
class Event
{
use Entities\MagicAccessors;
use Entities\Attributes\Identifier;
public function __construct()
{
$this->sites = new ArrayCollection();
$this->optItems = new ArrayCollection();
$this->registrations = new ArrayCollection();
}
/**
* @ORM\OneToMany(targetEntity="Site",cascade={"persist","remove"},mappedBy="event")
* @ORM\OrderBy({"name"="ASC"})
* @var ArrayCollection | Site[]
*/
private $sites;
function addSite(Site $site)
{
$this->sites[] = $site;
}
function getSites()
{
return $this->sites;
}
/**
* @ORM\OneToMany(targetEntity="OptItem",cascade={"persist","remove"},mappedBy="event")
* @ORM\OrderBy({"name"="ASC"})
* @var ArrayCollection | OptItem[]
*/
private $optItems;
function addOptItem(OptItem $optItem)
{
$this->optItems[] = $optItem;
}
function getOptItems()
{
return $this->optItems;
}
/**
* @ORM\Column(type="boolean")
*/
protected $visible;
/**
* @ORM\Column(type="string", length=32, nullable=false)
*/
protected $name;
/**
* @ORM\Column(type="string", length=32, nullable=false)
*/
protected $ename;
/**
* @ORM\Column(type="datetime", nullable=false)
*/
protected $regInt1;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $regInt2;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $regInt3;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $regInt4;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $regInt5;
/**
* @ORM\Column(type="datetime")
*/
protected $date;
/**
* @ORM\Column(type="boolean")
*/
protected $approve;
/**
* @ORM\Column(type="boolean")
*/
protected $regCars;
/**
* @ORM\Column(type="boolean")
*/
protected $optionalItems;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $note;
/**
* @ORM\OneToMany(targetEntity="Registration",cascade={"persist","remove"},mappedBy="event")
* @var ArrayCollection | Registration[]
*/
private $registrations;
function addRegistration(Registration $registration)
{
$this->registrations[] = $registration;
}
function getRegistrations()
{
return $this->registrations;
}
public function getArrayCopy()
{
return get_object_vars($this);
}
}
- petr.jirous
- Člen | 128
zkus tu entitu refreshnout a dej vedet jestli to zabralo
$em->refresh($entity);