我正在使用Zend_Auth(除其他外)使用Zend_Auth进行新的应用程序,但无论出于何种原因,此错误消息在任何位置完全随机出现(或者它接缝)
Zend_Session::start()- /home/hannes/workspace/develop/library/Zend/Session.php(Line:480):错误#8session_start()[function.session-start]:ps_files_cleanup_dir:opendir(/ var/lib/php5)失败:权限被拒绝( 13)阵列
我正在使用Zend_DB并尝试将charset更改为utf8,这里是代码:
config.ini:
[development]
db.host = "localhost"
db.username = "root"
db.password = "toor"
db.dbname = "db_whoopdiedo"
db.charset = "utf8"
Run Code Online (Sandbox Code Playgroud)
bootstrap.php:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function _initAutoload()
{
Zend_Registry::set(
'config',
new Zend_Config_Ini(APPLICATION_PATH.'/configs/config.ini', 'development')
);
Zend_Registry::set(
'db',
Zend_Db::factory('Pdo_Mysql', Zend_Registry::get('config')->db)
);
Zend_Registry::get('db')->setFetchMode(Zend_Db::FETCH_OBJ);
Zend_Registry::get('db')->query("SET NAMES 'utf8'");
Zend_Registry::get('db')->query("SET CHARACTER SET 'utf8'");
}
}
Run Code Online (Sandbox Code Playgroud)
我认为在配置中添加charset就足够了,但是只有在我直接使用以下设置时才应用它:
Zend_Registry::get('db')->query("SET NAMES 'utf8'");
Zend_Registry::get('db')->query("SET CHARACTER SET 'utf8'");
Run Code Online (Sandbox Code Playgroud)
我的问题:有没有更好的方法来设置charset,也许配置明智?
我使用Zend_Auth作为我的一个项目,但到目前为止还没有弄清楚如何设置会话的生命周期,或者如何扩展它(假设它应该运行5分钟并且应该在用户做出动作时重置为),这是我的初始化代码:
$authAdapter = new Zend_Auth_Adapter_DbTable($this->_model->pdo);
$authAdapter->setTableName('normal_folks')
->setIdentityColumn('username')
->setCredentialColumn('password');
$post = $this->_request->getPost();
$authAdapter->setIdentity($post['username'])
->setCredential($post['password']);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if($result->isValid())
{
$userInfo = $authAdapter->getResultRowObject(null, 'password');
$authStorage = $auth->getStorage();
$authStorage->write($userInfo);
if(strlen($post['refferer']) > 1){
header("Location: ".$post['refferer']);
}elseif(strlen($this->_request->getParam('ref_action')) > 1){
Zend_Controller_Action::_forward($this->_request->getParam('ref_action'),"admin",null,null);
}else{
Zend_Controller_Action::_forward("index","admin",null,null);
}
}
Run Code Online (Sandbox Code Playgroud)
蚂蚁这个我如何检查用户是否登录:
if(Zend_Auth::getInstance()->hasIdentity()){
echo "Woho!";
}else{
die("invalid-identity");
}
Run Code Online (Sandbox Code Playgroud)
它可能就在我面前,但我无法理解,帮助?请?好吗?:d
我按书安装了PHPUnit:
sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit
Run Code Online (Sandbox Code Playgroud)
包含路径添加在 /etc/php5/cli/php.ini
include_path = ".:/usr/share/php"
$ ls /usr/share/php/PHPUnit/
Extensions Framework
Run Code Online (Sandbox Code Playgroud)
但是现在,如果我想运行Zend Framework的测试
user@server:/var/www/page/tests$ ./runtests.sh
+ phpunit --verbose AllTests
./runtests.sh: line 72: phpunit: command not found
user@server:/var/www/page/tests$ php AllTests.php
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /var/www/page/tests/Zend/Acl/AclTest.php on line 37
Run Code Online (Sandbox Code Playgroud)
当然,phpunit: command not found当我尝试遵循Zend Framework Context之外的PHPUnit手册http://www.phpunit.de/manual/3.6/en/writing-tests-for-phpunit.html中的说明时,我也会得到一个.
我得到的感觉我在这里缺少必要的东西......
解决了
看起来PEAR频道存在问题,在添加其他2之后再次,它工作:
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
Run Code Online (Sandbox Code Playgroud) 鉴于我的Doctrine 2实体的这种设置:
App\Bundle\LorumBundle\Entity\Node:
type: entity
table: node
fields:
id:
id: true
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
created:
type: datetime
inheritanceType: SINGLE_TABLE
discriminatorColumn:
name: type
type: string
length: 255
discriminatorMap:
a: a
b: b
c: c
App\Bundle\LorumBundle\Entity\A:
type: entity
fields:
status:
type: boolean
App\Bundle\LorumBundle\Entity\B:
type: entity
fields:
status:
type: boolean
App\Bundle\LorumBundle\Entity\C:
type: entity
fields:
title:
type: string
Run Code Online (Sandbox Code Playgroud)
现在我想得到的基本上是A&B(不是C)类型的实体的混合列表status == true.
我可以像这样编写一个查询 - 使用instance of运算符将结果限制为我想要的子类但是我会得到一个错误因为我要匹配的属性(状态)没有映射到超类甚至强大的所有实体我想匹配反对它:
$queryBuilder->select('Node');
$queryBuilder->from('App\Bundle\LorumBundle\Entity\Node','Node');
$queryBuilder->add('where',$queryBuilder->expr()->orx(
'Offer INSTANCE OF AppLorumBundle:A',
'Offer INSTANCE …Run Code Online (Sandbox Code Playgroud) php ×4
zend-auth ×2
doctrine-orm ×1
lifetime ×1
mysql ×1
phpunit ×1
session ×1
zend-db ×1
zend-session ×1
zend-test ×1