|
|
@@ -118,17 +118,17 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
|
|
/**
|
|
|
* __construct() - Sets configuration options
|
|
|
*
|
|
|
- * @param Zend_Db_Adapter_Abstract $zendDb
|
|
|
+ * @param Zend_Db_Adapter_Abstract $zendDb If null, default database adapter assumed
|
|
|
* @param string $tableName
|
|
|
* @param string $identityColumn
|
|
|
* @param string $credentialColumn
|
|
|
* @param string $credentialTreatment
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function __construct(Zend_Db_Adapter_Abstract $zendDb, $tableName = null, $identityColumn = null,
|
|
|
+ public function __construct(Zend_Db_Adapter_Abstract $zendDb = null, $tableName = null, $identityColumn = null,
|
|
|
$credentialColumn = null, $credentialTreatment = null)
|
|
|
{
|
|
|
- $this->_zendDb = $zendDb;
|
|
|
+ $this->_setDbAdapter($zendDb);
|
|
|
|
|
|
if (null !== $tableName) {
|
|
|
$this->setTableName($tableName);
|
|
|
@@ -148,6 +148,32 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * _setDbAdapter() - set the database adapter to be used for quering
|
|
|
+ *
|
|
|
+ * @param Zend_Db_Adapter_Abstract
|
|
|
+ * @throws Zend_Auth_Adapter_Exception
|
|
|
+ * @return Zend_Auth_Adapter_DbTable
|
|
|
+ */
|
|
|
+ protected function _setDbAdapter(Zend_Db_Adapter_Abstract $zendDb = null)
|
|
|
+ {
|
|
|
+ $this->_zendDb = $zendDb;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * If no adapter is specified, fetch default database adapter.
|
|
|
+ */
|
|
|
+ if(null === $this->_zendDb) {
|
|
|
+ require_once 'Zend/Db/Table/Abstract.php';
|
|
|
+ $this->_zendDb = Zend_Db_Table_Abstract::getDefaultAdapter();
|
|
|
+ if (null === $this->_zendDb) {
|
|
|
+ require_once 'Zend/Auth/Adapter/Exception.php';
|
|
|
+ throw new Zend_Auth_Adapter_Exception('No database adapter present');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* setTableName() - set the table name to be used in the select query
|
|
|
*
|
|
|
* @param string $tableName
|