Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Mapped superclasses with Doctrine 2
    text
    copied!<p>For school i am making a php project that works with a ORM. Doctrine 2. It has to have a inheritance in it. I made the following setup and i want to print the customers on the screen.</p> <p>because of the required inheritance i would extend the class person on customer and user. This is how it is defined now</p> <pre><code>/** @MappedSuperclass */ class Person { /** @Id @Column(type="integer") */ protected $id; protected $name; protected $email; protected $bar; public function getId() { return $this-&gt;id; } public function getName() { return $this-&gt;name; } public function setName($name) { $this-&gt;name = $name; } public function getEmail() { return $this-&gt;email; } public function setEmail($email) { $this-&gt;email = $email; } public function getBar() { return $this-&gt;bar; } public function setBar($bar) { $this-&gt;bar = $bar; } </code></pre> <p>}</p> <pre><code>/** @Entity */ class Customer extends Person { protected $photo; protected $facebook; protected $orders = null; public function __construct() { $this-&gt;orders = new ArrayCollection(); } public function getPhoto() { return $this-&gt;photo; } public function setPhoto($photo) { $this-&gt;photo = $photo; } public function getFacebook() { return $this-&gt;facebook; } public function setFacebook($facebook) { $this-&gt;facebook = $facebook; } </code></pre> <p>}</p> <p>I can create the database and all query's are working, but if i try to run the customer query, i will get an error. All the other query that are not involved in a inheritance are working fine. So it is not the query or view that is giving the problem.</p> <p>This is the result of the query</p> <pre><code>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 no such column: p0_.id' in /Users/arcooverbeek/doctrine2-orm/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php:633 Stack trace: #0 /Users/arcooverbeek/doctrine2-orm/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php(633): PDO-&gt;query('SELECT p0_.id A...') #1 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(46): Doctrine\DBAL\Connection-&gt;executeQuery('SELECT p0_.id A...', Array, Array, NULL) #2 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/Query.php(260): Doctrine\ORM\Query\Exec\SingleSelectExecutor-&gt;execute(Object(Doctrine\DBAL\Connection), Array, Array) #3 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/AbstractQuery.php(733): Doctrine\ORM\Query-&gt;_doExecute() #4 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/AbstractQuery.php(535): Doctrine\ORM\AbstractQuery-&gt;execute(Array, 1) #5 /Applications/MAMP/htdocs/doc/repositories/CustomerRepository.php(13): Doctrine\ORM\Ab in /Users/arcooverbeek/doctrine2-orm/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php on line 633 </code></pre> <p>The database that is created looks line and has the fields that are defined in Person. One thing i noticed that there is also a person's table, wich i think is unnessery?</p> <p>I had a good look at the documentation. And google'd this error but it has not got me any furter.</p>
 

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