简体   繁体   English

带zf2的mongodb给出错误该类在链配置的名称空间中找不到

[英]mongodb with zf2 gives an error The class was not found in the chain configured namespaces

I know I miss something in the configuration. 我知道我错过了配置中的某些内容。 Can anyone provide the steps for this configuration Mongo is running in my terminal properly. 任何人都可以提供此配置的步骤吗?Mongo在我的终端中正常运行。 when connect with zend in sequential way it works . 当与zend按顺序连接时它起作用。 but in procedural way it gives error. 但以程序方式会产生错误。 this is global config file 这是全局配置文件

'driver' => array(
        'odm_default' => array(
            'class'   => 'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain',
            'drivers' => array()
        )
    ),

when I write 当我写

$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');

    $user = new User();
    $user->setName("Gembul");

    $dm->persist($user);

persist then it gives class not found error 坚持然后给类找不到错误

When I found this error then I modify my database class means that change the comments in my model class in document section . 当发现此错误时,我将修改数据库类,这意味着更改文档部分中模型类中的注释。

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/**
 * Description of User
 *
 * @author kiwitech
 */
/** @ODM\Document(collection="user") */
class Users 
{

protected $dm;
/** @ODM\Id */
 private $_id;

/** @ODM\Field(type="string") */
 private $_first_name;
/** @ODM\Field(type="string") */
  private $_last_name;
/** @ODM\Field(type="string") */
  private $_login_name;
/** @ODM\Field(type="string") */
private $_email;
/** @ODM\Field(type="string") */
private $tp_id;
/** @ODM\Field(type="string") */
 private $_is_active;
/** @ODM\Field(type="string") */
private $_role_id;

function get_id() {
    return $this->_id;
}

function get_first_name() {
    return $this->_first_name;
}

function get_last_name() {
    return $this->_last_name;
}

function get_login_name() {
    return $this->_login_name;
}

function get_email() {
    return $this->_email;
}

function getTp_id() {
    return $this->tp_id;
}

function get_is_active() {
    return $this->_is_active;
}

function get_role_id() {
    return $this->_role_id;
}

function set_id($_id) {
    $this->_id = $_id;
}

function set_first_name($_first_name) {
    $this->_first_name = $_first_name;
}

function set_last_name($_last_name) {
    $this->_last_name = $_last_name;
}

function set_login_name($_login_name) {
    $this->_login_name = $_login_name;
}

function set_email($_email) {
    $this->_email = $_email;
}

function setTp_id($tp_id) {
    $this->tp_id = $tp_id;
}

function set_is_active($_is_active) {
    $this->_is_active = $_is_active;
}

function set_role_id($_role_id) {
    $this->_role_id = $_role_id;
}

}

then I easily solve this bug :) 然后我轻松解决此错误:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ZF2-Doctrine2 MongoDB ODM-“在链配置名称空间中找不到该类” - ZF2 - Doctrine2 MongoDB ODM - “The class was not found in the chain configuration namespaces” Zend Framework 2 + Doctrine ODM,“在链配置的命名空间中找不到类”错误? - Zend Framework 2 + Doctrine ODM, “The Class was not found in the chain configured namespaces” error? 在链配置的命名空间AppBundle \\ Document中找不到类'Doctrine \\ ODM \\ MongoDB \\ Cursor' - The class 'Doctrine\ODM\MongoDB\Cursor' was not found in the chain configured namespaces AppBundle\Document 在ZF2控制器中找不到MongoDb - MongoDb not found in ZF2 controller 在链配置的名称空间\\ Document中找不到类'Calendar \\ Document \\ Calendar'? - class 'Calendar\Document\Calendar' was not found in the chain configured namespaces \Document? 在链配置的名称空间中找不到类“ App \\ Document \\ User” - The class 'App\Document\User' was not found in the chain configured namespaces ZF2,dctrine-mongodb和PHP7 - ZF2, doctrine-mongodb and PHP7 ZF2 ODM MongoDB“需要登录” - ZF2 ODM MongoDB “need to login” 我如何在Doctrine 2 ODM中使用mongoDB在zf2中保存数据? - how i save data in zf2 using mongoDB with Doctrine 2 ODM? 语法错误,意外的“ sidebar_bann”(T_ENCAPSED_AND_WHITESPACE),在使用MongoDB ODM和ZF2时预期为“]” - syntax error, unexpected ''sidebar_bann' (T_ENCAPSED_AND_WHITESPACE), expecting ']' when working with MongoDB ODM and ZF2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM