1

对于学校,我正在制作一个与 ORM 一起使用的 php 项目。教义 2. 它必须有继承。我做了以下设置,我想在屏幕上打印客户。

由于需要继承,我将在客户和用户上扩展类人。现在是这样定义的

/** @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;
}

}

我可以创建数据库并且所有查询都在工作,但是如果我尝试运行客户查询,我会收到错误消息。不涉及继承的所有其他查询都可以正常工作。因此,问题不是查询或视图。

这是查询的结果

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

创建的数据库看起来很整齐,并具有在 Person 中定义的字段。一件事我注意到还有一个人的桌子,我认为这是不合时宜的?

我仔细查看了文档。谷歌搜索了这个错误,但它并没有让我更进一步。

4

0 回答 0