gpt4 book ai didi

zend-framework - ZendFramework,带有 mongoDB 的 Doctrine 2 ODM - Hydrator 错误

转载 作者:可可西里 更新时间:2023-11-01 10:06:52 24 4
gpt4 key购买 nike

我将 Zend Framework 与 Doctrine 2 和 mongoDB 结合使用。到目前为止一切顺利。

现在我正在重写我的自定义验证类,以检查用户名是否已存在于数据库中。 (此代码适用于 ORM 和 MySQL,但现在不适用于 ODM 和 mongoDB)。

所以我的自定义验证类如下所示:

<?php

class Project_Validate_UsernameUnique extends Zend_Validate_Abstract {
const USERNAME_EXISTS = '';

protected $_messageTemplates = array (
self::USERNAME_EXISTS => "'%value%' is taken. Please choose another username."
);

public function isValid($value) {
// setting value for the form
$this->_setValue($value);

// get the document manager and repository
$front = Zend_Controller_Front::getInstance();
$dm = $front->getParam('bootstrap')->getResource('odm');
$userRepository = $dm->getRepository('Entities\User');

$user = $userRepository->findOneBy(array('username' => $value));

// if an user was found, return false
if ($user) {
$this->_error(self::USERNAME_EXISTS);
return false;
}
return true;
}
}

但是我在这里得到这个错误:

Warning:   file_put_contents(/Applications/XAMPP/xamppfiles/htdocs/project/application/models/Hydrators/EntitiesUserHydrator.php) [function.file-put-contents]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/project/library/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php on line 343

我也尝试了 findBy 并且没有数组注释(findByUsername 或 findOneByUsername),但我仍然收到此错误或不知何故“什么都没有”。使用 ORM 和 MySQL 它工作得很好,那么问题在哪里呢?

提前致谢!

最佳答案

您的 Hydrators 文件夹是否可由 PHP 写入?

关于zend-framework - ZendFramework,带有 mongoDB 的 Doctrine 2 ODM - Hydrator 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9087776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com