Php Zend框架&x27;方法“;init";不存在
当我提交帖子时,出现致命错误:Php Zend框架&x27;方法“;init";不存在,php,zend-framework,Php,Zend Framework,当我提交帖子时,出现致命错误: public function loginAction(){ if($_POST){ $data = $this->getRequest()->getPost(); $adapter = $this->Authorization($data); $auth = Zend_Auth::getInstance(); $re
public function loginAction(){
if($_POST){
$data = $this->getRequest()->getPost();
$adapter = $this->Authorization($data);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
}
}
我尝试使用以下选项禁用布局:
*Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message
'Method "init" does not exist and was not trapped in __call()' in
/home/pigusaku/domains/xxx.lt/public_html/my/library/Zend/Controller/Action.php:486
Stack trace:
#0 /home/pigusaku/domains/xxx.lt/public_html/my/library/Zend/Controller/Action.php(133): Zend_Controller_Action->__call('init', Array)
#1 /home/pigusaku/domains/xxx.lt/public_html/my/library/Zend/Controller/Action.php(133): ErrorController->init()
#2 /home/pigusaku/domains/xxx.lt/public_html/my/library/Zend/Controller/Dispatcher/Standard.php(281): Zend_Controller_Action->__construct(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http), Array)
#3 /home/pigusaku/domains/xxx.lt/public_html/my/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#4 /home/pigusaku/domains/xxx.lt/public_html/my/library/Zend/Application/Boot in /home/pigusaku/domains/xxx.lt/public_html/my/library/Zend/Controller/Plugin/Broker.php on line 336*
但也会出现同样的致命错误
我在这行中得到一个错误:
$this->_helper->layout()->disableLayout();
我的应用程序中哪里有问题?我认为错误来自您使用的
适配器。如果您是通过数据库表向用户发送信息,我建议您在SETATEAD中使用以下代码:
$result = $auth->authenticate($adapter);
公共函数登录(){
如果(美元邮政){
$data=$this->getRequest()->getPost();
$username=$data['username'];//设置凭证($password);
$auth=Zend_auth::getInstance();
$result=$auth->authenticate($authAdapter);
}
}
您也可以看到这一点,也可以参考
希望这会有所帮助
public function loginAction(){
if($_POST){
$data = $this->getRequest()->getPost();
$username = $data['username']; //<----get here the username field
$password = $data['password']; //<----get here the password field
$authAdapter = new Zend_Auth_Adapter_DbTable(
Zend_Db_Table::getDefaultAdapter(),
'users', //users table name, or by setTableName('users')
'username', // the username column, or by setIdentityColumn('username')
'password' // password column, or by setCredentialColumn('password')
);
$authAdapter->setIdentity($username)
->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
}
}