当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Db_Table_Abstract::setDefaultAdapter方法代码示例

本文整理汇总了PHP中Zend_Db_Table_Abstract::setDefaultAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table_Abstract::setDefaultAdapter方法的具体用法?PHP Zend_Db_Table_Abstract::setDefaultAdapter怎么用?PHP Zend_Db_Table_Abstract::setDefaultAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Db_Table_Abstract的用法示例。


在下文中一共展示了Zend_Db_Table_Abstract::setDefaultAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initSession

 /**
  * @todo expireSessionCookie()
  * @todo rememberMe(xx)
  * @todo forgetMe()
  * @see Zend_Registry::get('session');
  * @return Zend_Session_Namespace
  */
 protected function _initSession()
 {
     $options = $this->getOption('ca_mgr');
     $db = Zend_Db::factory($options['db']['session']['pdo'], $options['db']['session']);
     /**
      * automatically clean up expired session entries from session cache
      * use the modified and lifetime stamps to calculate expire time
      */
     if ($options['db']['session']['autocleanup'] == '1') {
         $stmt = $db->query('delete from front_session where (modified + lifetime * 2) < unix_timestamp()');
         # $stmt->execute();
     }
     //you can either set the Zend_Db_Table default adapter
     //or you can pass the db connection straight to the save handler $config
     // @see lifetimeColumn / lifetime / overrideLifetime, lifetime defaults to php.ini: session.gc_maxlifetime
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     $config = array('name' => 'front_session', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime');
     //create your Zend_Session_SaveHandler_DbTable and
     //set the save handler for Zend_Session
     Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
     // Zend_Session::rememberMe(7200);
     //start your session!
     Zend_Session::start();
     $session = new Zend_Session_Namespace();
     if (!isset($session->started)) {
         $session->started = time();
     }
     if (!isset($session->authdata)) {
         $session->authdata = array('authed' => false);
     }
     Zend_Registry::set('session', $session);
     return $session;
 }
开发者ID:NEOatNHNG,项目名称:cacert-testmgr,代码行数:40,代码来源:Bootstrap.php

示例2: _initDB

 /**
  * Inicializa a conexão com o banco de dados
  * Usa o Zend_Cache para o metadata das tabelas
  *
  * @uses Zend_Cache
  */
 protected function _initDB()
 {
     // Configura a conexão com o BD
     $config = new Zend_Config($this->getOptions());
     $db = Zend_Db::factory($config->resources->db);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
 }
开发者ID:realejo,项目名称:library-zf1,代码行数:13,代码来源:Bootstrap.php

示例3: _initDb

 /**
  * Store the db adapter in the registry
  * and set the default one for the mappers
  *
  * @return Zend_Db_Adapter_Abstract
  */
 protected function _initDb()
 {
     $db = $this->getPluginResource('db')->getDbAdapter();
     Zend_Registry::set('db', $db);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     return $db;
 }
开发者ID:nlenepveu,项目名称:testapp,代码行数:13,代码来源:Bootstrap.php

示例4: _initDb

 protected function _initDb()
 {
     $config = Zend_Registry::get('config');
     $options = $config->mtb->db->params;
     $db = Zend_Db::factory('PDO_MYSQL', $options);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
 }
开发者ID:bucknejo,项目名称:mtb,代码行数:7,代码来源:Bootstrap.php

示例5: tearDown

 /**
  * Cleans up the environment after running a test.
  */
 protected function tearDown()
 {
     $this->Feeds = null;
     // restore the old default db
     Zend_Db_Table_Abstract::setDefaultAdapter($this->oldDefaultDb);
     parent::tearDown();
 }
开发者ID:BGCX261,项目名称:zportal-svn-to-git,代码行数:10,代码来源:FeedsTest.php

示例6: run

 public function run()
 {
     // Lade Konfig
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     Zend_Registry::set('config', $config);
     // Erstelle DB Adapter
     $db = Zend_Db::factory($config->db);
     Zend_Registry::set('db', $db);
     Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Registry::get('db'));
     if (APPLICATION_ENV !== 'production') {
         $profiler = new Zend_Db_Profiler_Firebug('All Database Queries:');
         $profiler->setEnabled(true);
         $db->setProfiler($profiler);
     }
     $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => ''));
     $resourceLoader->addResourceType('plugins', 'plugins', 'Plugins');
     if (PHP_SAPI != 'cli') {
         $front = Zend_Controller_Front::getInstance();
         $front->registerPlugin(new Plugins_Stats());
         if (APPLICATION_ENV == 'production') {
             $front->registerPlugin(new Plugins_Cache());
         }
     }
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('_partials/controls.phtml');
     parent::run();
 }
开发者ID:network-splash,项目名称:prepaidvergleich24.info,代码行数:26,代码来源:Bootstrap.php

示例7: setDbAdapter

 public static function setDbAdapter()
 {
     $cnf = Zend_Registry::get('cnf');
     $db = Zend_Db::factory($cnf->db);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     Zend_Registry::set('db', $db);
 }
开发者ID:albertobraschi,项目名称:zstarter,代码行数:7,代码来源:Kernel.php

示例8: dispatchLoopStartup

 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $result = $auth->getStorage();
     $identity = $auth->getIdentity();
     $registry = Zend_Registry::getInstance();
     $config = Zend_Registry::get('config');
     $module = strtolower($this->_request->getModuleName());
     $controller = strtolower($this->_request->getControllerName());
     $action = strtolower($this->_request->getActionName());
     if ($identity && $identity != "") {
         $layout = Zend_Layout::getMvcInstance();
         $view = $layout->getView();
         $view->login = $identity;
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $id = $siteInfoNamespace->userId;
         $view->firstname = $siteInfoNamespace->Firstname;
         $username = $siteInfoNamespace->username;
         $password = $siteInfoNamespace->password;
         $db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $config->resources->db->params->host, 'username' => $username, 'password' => $password, 'dbname' => $config->resources->db->params->dbname));
         Zend_Db_Table_Abstract::setDefaultAdapter($db);
         return;
     } else {
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $siteInfoNamespace->requestURL = $this->_request->getParams();
         $this->_request->setModuleName('default');
         $this->_request->setControllerName('Auth');
         $this->_request->setActionName('login');
     }
 }
开发者ID:papoteur-mga,项目名称:phpip,代码行数:30,代码来源:AuthPlugin.php

示例9: routeShutdown

 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $useModule = array('default', 'mice');
     if (in_array($request->getModuleName(), $useModule) and $this->getRequest()->getParam('language') != 'scripts') {
         Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Registry::get('read'));
     } else {
         Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Registry::get('write'));
     }
     if (in_array($request->getModuleName(), $useModule) and $this->getRequest()->getParam('language') != 'scripts') {
         $language = $this->getRequest()->getParam('language');
         if (empty($language)) {
             $language = 'id';
         }
         // Model
         $dictionaryDb = new Model_DbTable_Dictionary();
         $languageDb = new Model_DbTable_Language();
         // Data
         $dictionary = $dictionaryDb->getDictionaryArray($language);
         $languageId = $languageDb->getIdByName($language);
         try {
             // Translator Zend
             $translate = new Zend_Translate('array', $dictionary, $language);
             // Set registry
             Zend_Registry::set('Zend_Translate', $translate);
             Zend_Registry::set('language', $language);
             Zend_Registry::set('languageId', $languageId['language_id']);
             Zend_Registry::set('languageText', $languageId['language_text']);
         } catch (Zend_Translate_Exception $zte) {
         } catch (Zend_Exception $ze) {
         }
     }
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:32,代码来源:Language.php

示例10: testAction

 public function testAction()
 {
     $time_start = microtime(true);
     $params = array('host' => '127.0.0.1', 'username' => 'root', 'password' => 'root', 'dbname' => 'langithp');
     $db = Zend_Db::factory('PDO_MYSQL', $params);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     require_once '/Users/n/Documents/Work/Zend/kutump/test/CatalogAttribute.php';
     $tbl = new CatalogAttribute();
     $rows = $tbl->fetchAll();
     $num = count($rows);
     echo "<b><center>Database Output</center></b><br><br>";
     $i = 0;
     for ($i = 0; $i < $num; $i++) {
         //$tmpGuid = mysql_result($result,$i,"guid");
         $row = $rows->current();
         $tmpGuid = $row->title;
         echo '<br>' . $tmpGuid;
         echo '<br>' . $i;
         $rows->next();
         //$i++;
     }
     $dbh = null;
     echo '<br>Total: ' . $i;
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     echo '<br>WAKTU EKSEKUSI: ' . $time;
     //die('hiho');
 }
开发者ID:psykomo,项目名称:kutump,代码行数:28,代码来源:IndexController.php

示例11: __construct

 function __construct()
 {
     $options = array('host' => 'localhost', 'username' => 'root', 'password' => 'root', 'dbname' => 'zendcastdev');
     $this->db = Zend_Db::factory('PDO_MYSQL', $options);
     Zend_Db_Table_Abstract::setDefaultAdapter($this->db);
     $this->users = new UsersTable();
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:7,代码来源:UserService.php

示例12: init_zend_db

/**
 * Initizlize Zend DB
 */
function init_zend_db()
{
    try {
        include APPPATH . 'config' . DIRECTORY_SEPARATOR . 'database.php';
        $__dbParams = array('host' => $db[$active_group]['hostname'], 'username' => $db[$active_group]['username'], 'password' => $db[$active_group]['password'], 'dbname' => $db[$active_group]['database'], 'persistent' => $db[$active_group]['pconnect']);
        $__db = Zend_Db::factory('PDO_MYSQL', $__dbParams);
        include APPPATH . 'config/cache.php';
        $feEngine = $config['dbschema_frontend_engine'];
        $feOptions = $config['dbschema_frontend'];
        $beEngine = $config['dbschema_backend_engine'];
        $beOptions = $config['dbschema_backend'];
        if (isset($beOptions['cache_dir']) && !file_exists($beOptions['cache_dir'])) {
            mkdir($beOptions['cache_dir']);
            chmod($beOptions['cache_dir'], 0777);
        }
        //      var_dump($beOptions['cache_dir']);
        $cache = Zend_Cache::factory($feEngine, $beEngine, $feOptions, $beOptions);
        Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
        Zend_Db_Table_Abstract::setDefaultAdapter($__db);
        Profiler::start($db[$active_group], $__db);
        $__db->query('SET NAMES ' . $db['default']['char_set']);
        $__db->query('SET SQL_MODE = "NO_UNSIGNED_SUBTRACTION"');
    } catch (Exception $e) {
        header("HTTP/1.1 500 Internal Server Error (DB)");
        echo $e->getMessage();
        exit;
    }
}
开发者ID:sabril-2t,项目名称:Open-Ad-Server,代码行数:31,代码来源:zend.php

示例13: __construct

 public function __construct()
 {
     //set country
     //lookup country from subdomain
     // must be format like http://country.site.org
     $parts = explode('.', $_SERVER['HTTP_HOST']);
     self::$COUNTRY = $parts[0];
     require_once 'settings.php';
     $countryLoaded = false;
     if ($parts[1] == 'trainingdata') {
         Settings::$DB_DATABASE = Globals::$DB_TABLE_PREFIX . $parts[0];
         self::$COUNTRY = $parts[0];
         Settings::$COUNTRY_BASE_URL = 'http://' . $parts[0] . '.' . Globals::$DOMAIN;
         $countryLoaded = true;
     }
     error_reporting(E_ALL);
     // PATH_SEPARATOR =  ; for windows, : for *nix
     $iReturn = ini_set('include_path', Globals::$BASE_PATH . PATH_SEPARATOR . Globals::$BASE_PATH . 'app' . PATH_SEPARATOR . (Globals::$BASE_PATH . 'ZendFramework' . DIRECTORY_SEPARATOR . 'library') . PATH_SEPARATOR . ini_get('include_path'));
     require_once 'Zend/Loader.php';
     if ($countryLoaded) {
         //fixes mysterious configuration issue
         require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
         require_once 'Zend/Db.php';
         //set a default database adaptor
         $db = Zend_Db::factory('PDO_MYSQL', array('host' => Settings::$DB_SERVER, 'username' => Settings::$DB_USERNAME, 'password' => Settings::$DB_PWD, 'dbname' => Settings::$DB_DATABASE));
         require_once 'Zend/Db/Table/Abstract.php';
         Zend_Db_Table_Abstract::setDefaultAdapter($db);
     }
 }
开发者ID:falafflepotatoe,项目名称:trainsmart-code,代码行数:29,代码来源:globals.php

示例14: _initDb

 public function _initDb()
 {
     $resource = $this->getPluginResource('db');
     $options = $resource->getOptions();
     $db = new Zend_Db_Adapter_Pdo_Mysql($options["params"]);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
 }
开发者ID:hocondoimeo,项目名称:giasu-tam.com,代码行数:7,代码来源:Bootstrap.php

示例15: _initSession

 /**
  * initalize session
  */
 protected function _initSession()
 {
     $resource = $this->getPluginResource('db');
     $db = $resource->getDbAdapter();
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     $config = array('name' => 'sessions', 'primary' => 'sessionId', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime', 'lifetime' => 60 * 60 * 24 * 14);
     Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
 }
开发者ID:AlexanderMazaletskiy,项目名称:gym-Tracker-App,代码行数:11,代码来源:Bootstrap.php


注:本文中的Zend_Db_Table_Abstract::setDefaultAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。