Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony 2 class table inheritance fixture SQL error
    primarykey
    data
    text
    <p>I'm new here and quite new to symfony 2.</p> <p>I try to build an Entity 'MailProcess' that inherits from an Entity 'Process'. Here are my Entity definitions:</p> <pre><code>// src/MW/TodoBundle/Entity/Process.php namespace MW\TodoBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="process_type", type="string") * @ORM\DiscriminatorMap({"mailprocess" = "MailProcess", "process" = "Process"}) * @ORM\Table(name="process") * @ORM\HasLifecycleCallbacks */ class Process { /** * * @ORM\Id * @ORM\Column(type="integer", unique=true) * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * * @ORM\Column(type="string") */ protected $title; /** * * @ORM\Column(type="datetime") */ protected $created; /** * * @ORM\Column(type ="text", nullable= true) */ protected $comment; protected $options; // Getters and Setters } // src/MW/TodoBundle/Entity/MailProcess.php namespace MW\TodoBundle\Entity; use Doctrine\ORM\Mapping as ORM; use MW\TodoBundle\Entity\Process; /** * * @ORM\Entity * @ORM\Table(name="process_mailprocess") */ class MailProcess extends Process { /** * * @ORM\Column(type="string") */ protected $from; /** * * @ORM\Column(type="string") */ protected $to; /** * * @ORM\Column(type="string", nullable=true) */ protected $subject; /** * * @ORM\Column(type="text", nullable=true) */ protected $message; } </code></pre> <p>You can see the ORM Class Table Inheritance used: Two tables 'process' and 'process_mailprocess' with discriminator column 'process_type'.</p> <p>I do use ´php app/console doctrine:schema:update --force´ to update the schema to my MySQL database which works fine.</p> <p>But then there are my Data fixtures: I've stripped them down to one here, but be assured I have additional fixtures also testing the Entity 'Process' which are working fine.</p> <pre><code>// src/MW/TodoBundle/DataFixtures/ORM/ProcessFixtures.php namespace MW\TodoBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\Common\Persistence\ObjectManager; use MW\TodoBundle\Entity\Process; use MW\TodoBundle\Entity\MailProcess; class ProcessFixtures implements FixtureInterface { public function load(ObjectManager $manager) { $mp1= new MailProcess(); $mp1-&gt;setTitle("Invoice from heaven") -&gt;setComment("sitebot: Irgendwer will was von euch!") -&gt;setCreated(new \DateTime()) -&gt;setFrom("m") -&gt;setTo("m") -&gt;setSubject("m") -&gt;setMessage("m"); $manager-&gt;persist($mp1); $manager-&gt;flush(); } } </code></pre> <p>Alas, execution of ´php app/console doctrine:fixtures:load´ confirming 'y' to purge gets me</p> <pre><code> [Doctrine\DBAL\DBALException] An exception occurred while executing 'INSERT INTO process_mailprocess (id, from, to, subject, message) VALUES (?, ?, ?, ?, ?)' with params {"1":28,"2":"m","3":"m","4":"m","5":"m"}: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from, to, subject, message) VALUES ('28 ', 'm', 'm', 'm', 'm')' at line 1 [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from, to, subject, message) VALUES ('28 ', 'm', 'm', 'm', 'm')' at line 1 </code></pre> <p>I can see nothing wrong there, and besides, Doctrine and Symfony create the SQL query. Can anyone point me to what I am doing wrong here? This is a real head-scratcher for me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload