2
我使用Zend Framework與Doctrine 2和mongoDB結合使用。 目前爲止這麼好。ZendFramework,Doctrine 2 ODM與mongoDB - Hydrator錯誤
現在我正在重寫自定義驗證類,以檢查數據庫中是否已存在用戶名。 (這段代碼在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它工作完美,所以問題在哪裏?
在此先感謝!
嘿男人!這正是重點!我的主文件夾是可寫的,但是我忘了將它添加到封閉的項目中!非常感謝!你讓我今天一整天都感覺很好! =) – pvlsgnnks 2012-02-01 11:32:23
Thax很多傢伙=)。雖然我不知道我們爲什麼使用它! – 2013-02-11 10:56:18