Hallo zusammen.
Ich schlage mich seit einiger Zeit mit einem offensichtlich falsch erstellten Query herum und finde meinen Fehler nicht.
Ich folge aktuell dem Beispielplugin aus dem Entwicklerhandbuch (LoremQuestions).
Dabei bekomme ich nachdem ich die Models Question und Answer hinzugefügt habe folgenden Fehler:
[Doctrine\ORM\ORMException]
Column nameid
referenced for relation from LoremQuestions\Models\Answer towards LoremQuestions\Models\Question does not exist.
Ich konnte mittlerweile auch bestätigen, dass die Spalte id
nicht angelegt wird von Doctrine.
Danke schon einmal im Vorraus, wenn sich jemand bereit erklärt mir zu helfen.
Nachfolgend Infos zu System und Dateien
- php Version: 7.0.13
- Shopwareversion: 5.4.5
- Mysql Version: 5.5.61
Hier das Query dazu (von Doctrine erstellt):
CREATE TABLE lorem_questions (
question INT AUTO_INCREMENT NOT NULL,
time DATETIME NOT NULL,
user_id INT DEFAULT NULL,
article_id INT NOT NULL,
INDEX IDX_DF824069A76ED395 (user_id),
INDEX IDX_DF8240697294869C (article_id),
PRIMARY KEY(question)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
Hier die Models\Question:
namespace LoremQuestions\Models;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Shopware\Components\Model\ModelEntity;
/**
* @ORM\Entity(repositoryClass="Repository")
* @ORM\Table(name="lorem_questions")
*/
class Question extends ModelEntity
{
/**
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(name="question", type="string", nullable=false)
*/
private $question;
/**
* @ORM\Column(name="time", type="datetime", nullable=false)
*/
private $time;
/**
* @ORM\ManyToOne(targetEntity="Shopware\Models\Customer\Customer")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $customer;
/**
* @ORM\ManyToOne(targetEntity="Shopware\Models\Article\Article")
* @ORM\JoinColumn(name="article_id", referencedColumnName="id", nullable=false)
*/
protected $article;
/**
* @ORM\OneToMany(targetEntity="LoremQuestions\Models\Answer", mappedBy="question", orphanRemoval=true, cascade={"persist"})
*/
protected $answers;
public function __construct()
{
$this->time = new \DateTime();
$this->answers = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getQuestion()
{
return $this->question;
}
public function setQuestion($question)
{
$this->question = $question;
}
public function getTime()
{
return $this->time;
}
public function setTime($time)
{
$this->time = $time;
}
public function getCustomer()
{
return $this->customer;
}
public function setCustomer($customer)
{
$this->customer = $customer;
return $this;
}
public function getArticle()
{
return $this->article;
}
public function setArticle($article)
{
$this->article = $article;
return $this;
}
public function getAnswers()
{
return $this->answers;
}
public function setAnswers($answers)
{
return $this->setOneToMany($answers, '\LoremQuestions\Models\Answer', 'answers', 'question');
}
}
Und schließlich die Models\Answer:
namespace LoremQuestions\Models;
use Doctrine\ORM\Mapping as ORM;
use Shopware\Components\Model\ModelEntity;
/**
* @ORM\Entity(repositoryClass="Repository")
* @ORM\Table(name="lorem_answers")
*/
class Answer extends ModelEntity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(name="time", type="datetime", nullable=false)
*/
private $time;
/**
* @ORM\Column(name="answer", type="string", nullable=false)
*/
private $answer;
/**
* @ORM\ManyToOne(targetEntity="Shopware\Models\Customer\Customer")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $customer;
/**
* @ORM\ManyToOne(targetEntity="\LoremQuestions\Models\Question", inversedBy="answers")
* @ORM\JoinColumn(name="question_id", referencedColumnName="id")
*/
protected $question;
public function __construct()
{
$this->time = new \DateTime();
}
public function getId()
{
return $this->id;
}
public function getTime()
{
return $this->time;
}
public function setTime($time)
{
$this->time = $time;
}
public function getAnswer()
{
return $this->answer;
}
public function setAnswer($answer)
{
$this->answer = $answer;
}
public function getCustomer()
{
return $this->customer;
}
public function setCustomer($customer)
{
$this->customer = $customer;
return $this;
}
public function getQuestion()
{
return $this->question;
}
public function setQuestion($question)
{
$this->question = $question;
return $this;
}
}