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.
because of the required inheritance i would extend the class person on customer and user. This is how it is defined now
/** @MappedSuperclass */
class Person {
/** @Id @Column(type="integer") */
protected $id;
protected $name;
protected $email;
protected $bar;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
}
public function getBar()
{
return $this->bar;
}
public function setBar($bar)
{
$this->bar = $bar;
}
}
/** @Entity */
class Customer extends Person
{
protected $photo;
protected $facebook;
protected $orders = null;
public function __construct()
{
$this->orders = new ArrayCollection();
}
public function getPhoto()
{
return $this->photo;
}
public function setPhoto($photo)
{
$this->photo = $photo;
}
public function getFacebook()
{
return $this->facebook;
}
public function setFacebook($facebook)
{
$this->facebook = $facebook;
}
}
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.
This is the result of the query
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->query('SELECT p0_.id A...')
#1 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(46): Doctrine\DBAL\Connection->executeQuery('SELECT p0_.id A...', Array, Array, NULL)
#2 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/Query.php(260): Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(Object(Doctrine\DBAL\Connection), Array, Array) #3 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/AbstractQuery.php(733): Doctrine\ORM\Query->_doExecute()
#4 /Users/arcooverbeek/doctrine2-orm/lib/Doctrine/ORM/AbstractQuery.php(535): Doctrine\ORM\AbstractQuery->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
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?
I had a good look at the documentation. And google'd this error but it has not got me any furter.