当我尝试添加带有教义的记录时,我收到此错误消息“消息:类“Application_Model_MbsUsers”不是有效实体或映射的超类。
这是我使用的代码
require APPLICATION_PATH . '/' . 'models/Application_Model_MbsUsers.php';
$user = new Application_Model_MbsUsers;
$user->setDisplayName( 'moahemd' );
$user->setUserLogin( 'adminss' );
$user->setUserPass( 'password' );
$user->setUserActivationKey( 'aass' );
$user->setUserRegistered( null );
$user->setUserEmail( 'eng.sda@yahoo.com' );
$user->setUserRole( 'admin' );
$this->getRequest()->_em->persist( $user );
$this->getRequest()->_em->flush();
我把我的实体放在模型文件夹'application\models'中
这是我的引导代码
protected function _initDoctrine()
{
# doctrine loader
require_once (APPLICATION_PATH .
DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR . 'library' .
DIRECTORY_SEPARATOR . 'Doctrine' .
DIRECTORY_SEPARATOR . 'Common' .
DIRECTORY_SEPARATOR . 'ClassLoader.php'
);
$doctrineAutoloader = new \Doctrine\Common\ClassLoader('Doctrine', APPLICATION_PATH .
DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR . 'library'
);
$doctrineAutoloader->register();
# configure doctrine
$cache = new Doctrine\Common\Cache\ArrayCache;
$config = new Configuration;
$config->setMetadataCacheImpl( $cache );
echo APPLICATION_PATH . DIRECTORY_SEPARATOR . 'models';
$driverImpl = $config->newDefaultAnnotationDriver( APPLICATION_PATH . DIRECTORY_SEPARATOR . 'models' );
$config->setMetadataDriverImpl( $driverImpl );
$config->setQueryCacheImpl( $cache );
$config->setProxyDir( APPLICATION_PATH );
$config->setProxyNamespace( 'Proxies' );
$config->setAutoGenerateProxyClasses( TRUE );
$this->_registry->doctrine = new stdClass();
$this->_registry->doctrine->_em = EntityManager::create( $this->_registry->config->application->doctrine->connection->toArray(), $config );
}
和我的实体
使用 Doctrine\ORM\Mapping 作为 ORM;
/**
* Application_Model_MbsUsers
*
* @ORM\Table(name="mbs_users")
* @ORM\Entity
*/
class Application_Model_MbsUsers
{
/**
* @var string
*
* @ORM\Column(name="user_login", type="string", length=64, nullable=false)
*/
private $userLogin;
/**
* @var string
*
* @ORM\Column(name="user_pass", type="string", length=64, nullable=false)
*/
private $userPass;
......
我想知道为什么会出现这个问题,我用谷歌搜索并找不到解决方案,所以你能帮助我的人吗......