Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Auth: not working, getDbSelect() is empty
    primarykey
    data
    text
    <p>my authentication fails and when i try to getDbSelect() i get nothing ... what did i do wrong? </p> <pre> class AuthController extends Zend_Controller_Action { protected $auth; public function init() { $db = $this->getInvokeArg("bootstrap")->getResource("db"); $this->auth = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password', 'md5(?)'); } public function loginAction() { if (isset($_POST["username"])) { $result = $this->auth ->setIdentity($this->getRequest()->getParam('username')) ->setCredential($this->getRequest()->getParam('password')); echo " > " . $this->auth->getDbSelect();die(); $result = $this->auth ->setIdentity($this->getRequest()->getParam('username')) ->setCredential($this->getRequest()->getParam('password')) ->authenticate(); if ($result->isValid()) { $this->_redirect("postLogin"); } } } </pre> <h1>Update 1:</h1> <p>i also tried without MVC and with MySQL which i am more familiar with:</p> <pre> // setup auto loading require_once 'Zend/Loader/Autoloader.php'; Zend_Loader_Autoloader::getInstance(); // setup db connection $db = new Zend_Db_Adapter_Pdo_Mysql(array( 'host' => '127.0.0.1', 'username' => 'root', 'password' => '', 'dbname' => 'learnZendAuth' )); // create authentication adapter $auth = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password', 'md5(?)'); // do login if request is posted if (isset($_POST) && !empty($_POST)) { // do authencation $result = $auth->setIdentity($_POST['username']) ->setCredential($_POST['password']) ->authenticate(); // check authentication valid if ($result->isValid()) { // login success echo "successfully logged in as: " . $result->getIdentity(); } else { // login fail echo "<pre>"; print_r($result->getMessages()); echo "</pre>"; } } else { // request not posted // see if already logged in if (Zend_Auth::getInstance()->hasIdentity()) { echo "already logged in as: " . Zend_Auth::getInstance()->getIdentity(); } } </pre> <p>i get </p> <blockquote> <p>Fatal error: Uncaught exception 'Zend_Auth_Adapter_Exception' with message 'The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and column names for validity.' in C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library\Zend\Auth\Adapter\DbTable.php:414 Stack trace: #0 C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library\Zend\Auth\Adapter\DbTable.php(306): Zend_Auth_Adapter_DbTable->_authenticateQuerySelect(Object(Zend_Db_Select))</p> <h1>1 C:\Program Files (x86)\Zend\Apache2\htdocs\learnZf\index.php(23):</h1> <p>Zend_Auth_Adapter_DbTable->authenticate()</p> <h1>2 {main} thrown in C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library\Zend\Auth\Adapter\DbTable.php</h1> <p>on line 414</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload