在zend framework2中调用DbTableAuthAdapter类中的过程


Calling procedure in DbTableAuthAdapter class in zend framework2

我正在使用zend framework2,并尝试使用zend framework2的DbTableAuthAdapter类登录用户,如下所示

 $authAdapter=new DbTableAuthAdapter($dbAdapter,'login_user','username','password','is_active=1');

但我想调用一个类似的过程

 $authAdapter=new DbTableAuthAdapter($dbAdapter,'CALL `sp_user_login`(?, ?)');

是否存在我调用过程而不是绑定实体的情况?

                          OR

任何人都告诉我我下面的代码出了什么问题

   use Zend'Authentication'Adapter'DbTable as AuthAdapter;
   $hashPassword=hash("sha256", $data["password"]);
   $subQuery="select zend_with_procedure.login_user.hash_salt from   zend_with_procedure.login_user where  zend_with_procedure.login_user.username='".$data['username']."'";
   $authAdapter=new AuthAdapter($dbAdapter,'login_user','username','password','concat('.$subQuery.','.$hashPassword.') AND is_active=1');
   $authAdapter->setIdentity($data['username']);
   $authAdapter->setCredential($data['password']);
   $auth=new AuthenticationService();
   $result=$auth->authenticate($authAdapter);

我输入了正确的用户名和密码,它显示我无效的凭据为什么,有人知道吗???

   use Zend'Authentication'Adapter'DbTable as AuthAdapter;
   $hashPassword=hash("sha256", $data["password"]);
   $subQuery="select zend_with_procedure.login_user.hash_salt from   zend_with_procedure.login_user where  zend_with_procedure.login_user.username='".$data['username']."'";

//更改此行$authAdapter=new authAdapter($dbAdapter,'login_user','sername','password','ncat('.$subQuery.','.$hashPassword.')AND is_active=1');to$authAdapter=新的authAdapter($dbAdapter,'login_user','username','password',"concat(".$subQuery.",?)AND is_active=1")

   $authAdapter=new AuthAdapter($dbAdapter,'login_user','username','password',"concat(".$subQuery.",?) AND is_active=1");
   $authAdapter->setIdentity($data['username']);

更改此行$authAdapter->setCredential($data['password']);到$authAdapter->setCredential($hashPassword)

   $authAdapter->setCredential($hashPassword);
   $auth=new AuthenticationService();
   $result=$auth->authenticate($authAdapter);

但没有找到调用过程的解决方案!!!

我不知道你使用的是哪一个版本的ZF2,但似乎有一个新的CallbackCheckAdapter,至少从版本2.2:开始

http://framework.zend.com/apidoc/2.2/classes/Zend.Authentication.Adapter.DbTable.CallbackCheckAdapter.html

也许使用它可以调用存储过程?