0

I am new in Zend Framwork. I write a action for login is given below :

public function authAction()
{
    $request = $this->getRequest();
    $registry = Zend_Registry::getInstance();
    $auth = Zend_Auth::getInstance();
    $DB = $registry['rdvs'];
    $authAdapter = new Zend_Auth_Adapter_DbTable($DB);
    $authAdapter->setTableName('user')
                ->setIdentityColumn('user_name')
                ->setCredentialColumn('password');    

    // Set the input credential values
    $uname = $request->getParam('username');
    $paswd = $request->getParam('pwd');
    $authAdapter->setIdentity($uname);
    $authAdapter->setCredential(md5($paswd));

    // Perform the authentication query, saving the result
    $result = $auth->authenticate($authAdapter);

    if($result->isValid()){
      //print_r($result);   
      $data = $authAdapter->getResultRowObject(null,'password');
      $auth->getStorage()->write($data);
      $this->_redirect('/service/');
    }else{
      $this->_redirect('/index/');
    }

}

When i rum my web app then its given Exception : Message: No database adapter present I don't understand where i difine database or phpmyadmin connection.

0

2 Answers 2

0

replace

$DB = $registry['rdvs'];

with

$DB = Zend_Db_Table::getDefaultAdapter();

I hope you have setup your db configuration in your application.ini properly if not then

append the following in [production] section of your application.ini and setup the values accordingly like username , password , dbname

resources.db.adapter = PDO_MYSQL
resources.db.isDefaultAdapter = true
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = 
resources.db.params.dbname = myDbName
1
  • Sir, I don't configure any thing in my application.ini file please tell me how can i configure my application.ini file. What change i can do? Sep 22, 2011 at 14:30
0

It's likely that something is messed up in the registry object. What you can do, instead, is when you create the database connection call Zend_Db_Table_Abstract::setDefaultAdapter($db) instead of putting it into the registry. Most of the components in ZF will look there if a database adapter isn't explicitly given to them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.