mongodb with zf2 给出错误 The class was not found in the chain configured namespaces
mongodb with zf2 gives an error The class was not found in the chain configured namespaces
我知道我在配置中遗漏了一些东西。
谁能提供此配置的步骤
Mongo 在我的终端中正确地是 运行。
当以顺序方式连接 zend 时,它会起作用。但以程序方式给出错误。
这是全局配置文件
'driver' => array(
'odm_default' => array(
'class' => 'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain',
'drivers' => array()
)
),
当我写
$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');
$user = new User();
$user->setName("Gembul");
$dm->persist($user);
坚持然后它给出 class 未找到错误
当我发现这个错误时,我修改了我的数据库 class 意味着更改我的模型中的评论 class 在文档部分。
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;
}
}
那我就轻松解决了这个bug:)
我知道我在配置中遗漏了一些东西。 谁能提供此配置的步骤 Mongo 在我的终端中正确地是 运行。 当以顺序方式连接 zend 时,它会起作用。但以程序方式给出错误。 这是全局配置文件
'driver' => array(
'odm_default' => array(
'class' => 'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain',
'drivers' => array()
)
),
当我写
$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');
$user = new User();
$user->setName("Gembul");
$dm->persist($user);
坚持然后它给出 class 未找到错误
当我发现这个错误时,我修改了我的数据库 class 意味着更改我的模型中的评论 class 在文档部分。
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;
}
}
那我就轻松解决了这个bug:)