【发布时间】:2015-05-24 12:02:17
【问题描述】:
我是教义的新手。我试图将 Doctrine 集成到我的 CodeIgniter 实例中,但出现错误:
类“用户”不是有效的实体或映射的超类。
实体用户被自动删除,如下所示:
use Doctrine\ORM\Mapping as ORM;
/**
* User
*
* @ORM\Table(name="user")
* @ORM\Entity
*/
class User
{
/**
* @var string
*
* @ORM\Column(name="uid", type="string", length=255, nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $uid;
/**
* @var \DateTime
*
* @ORM\Column(name="cr_date", type="datetime", nullable=false)
*/
private $crDate = 'CURRENT_TIMESTAMP';
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=255, nullable=false)
*/
eaccelerator 在我的 php.ini 文件中被禁用并被加载。
Doctrine 知道其配置中的正确路径。
回溯如下所示:
回溯:
文件: /var/www/dadgehog/ci/application/third_party/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php 行:89 函数:classIsNotAValidEntityOrMappedSuperClass
文件: /var/www/dadgehog/ci/application/third_party/Doctrine/ORM/Mapping/ClassMetadataFactory.php 行:117 函数:loadMetadataForClass
文件: /var/www/dadgehog/ci/application/third_party/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php 行:332 功能:doLoadMetadata
文件: /var/www/dadgehog/ci/application/third_party/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php 行:216 功能:loadMetadata
文件: /var/www/dadgehog/ci/application/third_party/Doctrine/ORM/EntityManager.php 行:360 功能:getMetadataFor
文件:/var/www/dadgehog/ci/application/models/Usermodel.php 行:36 功能:查找
文件:/var/www/dadgehog/ci/application/controllers/Login.php 行:23 功能:获取用户
文件:/var/www/dadgehog/index.php 行:292 功能:require_once
如果有人有想法指出这一点,我会很高兴。
【问题讨论】:
-
是
User.php控制器吗? -
User.php 是一个实体。它存储在文件夹应用程序/模型/实体中。相关模型是Usermodel.php,我在其中尝试访问Doctrine实体管理器的神奇方法find
-
集成 Doctrine 时遵循了哪些文档?你试过these steps吗?
-
是的,我用的是官方的。在博客中,我发现 EntityGenerator 的提示可以自动创建我的数据库的所有实体
-
我想通了一点。我调试了 Doctrine 文件解析器。它无法正确读取注释。但该文件在第一个视图中似乎没问题。 DocParser::Annotations 只是遍历文件而没有任何注释
标签: php codeigniter doctrine