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


PHP Zend_Db_Table::setDefaultAdapter方法代码示例

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


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

示例1: _initDb

 public function _initDb()
 {
     $dbconf = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     Zend_Registry::set('Zend_Db', Zend_Db::factory($dbconf->resources->db));
     Zend_Registry::get('Zend_Db')->setFetchMode(Zend_Db::FETCH_OBJ);
     Zend_Db_Table::setDefaultAdapter(Zend_Registry::get('Zend_Db'));
 }
开发者ID:nishant3001,项目名称:canopy,代码行数:7,代码来源:Bootstrap.php

示例2: __construct

 public function __construct($addr = "127.0.0.1", $port = 8080)
 {
     $this->port = $port;
     $this->addr = $addr;
     // Setup basic stuff
     error_reporting(E_ALL & ~E_NOTICE);
     $base = realpath(dirname(__FILE__) . '/../');
     $paths = array('.', realpath($base . '/library'), get_include_path());
     $this->base = $base;
     // Setup autoloading ...
     set_include_path(implode(PATH_SEPARATOR, $paths));
     require_once 'Zend/Loader/Autoloader.php';
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->registerNamespace('EvHttp_');
     $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => realpath($base . '/application'), 'namespace' => '', 'resourceTypes' => array('model' => array('namespace' => 'Model', 'path' => 'models/'), 'api' => array('namespace' => 'Service', 'path' => 'apis/'))));
     // Load config
     $this->config = new Zend_Config_Ini($this->base . '/deploy/config.ini', 'default');
     Zend_Registry::set('config', $this->config);
     // Connect database
     $dbType = $this->config->database->type;
     $params = $this->config->database->toArray();
     $db = Zend_Db::factory($dbType, $params);
     Zend_Db_Table::setDefaultAdapter($db);
     Zend_Registry::set('db', $db);
     // Setup Xml-Rpc Server
     $this->xmlrpc_server = new Zend_XmlRpc_Server();
     $this->xmlrpc_server->setClass('Service_Poll', 'poll');
     Zend_XmlRpc_Server_Fault::attachFaultException('Exception');
     // Setup Json-Rpc Server
     $this->jsonrpc_server = new Zend_Json_Server();
     $this->jsonrpc_server->setClass('Service_Poll', 'poll')->setAutoEmitResponse(false)->setTarget('/jsonrpc')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
 }
开发者ID:dreamsxin,项目名称:Kellner,代码行数:32,代码来源:main.php

示例3: _initDb

 /**
  *  Instantiate the application database resource object
  *
  *  @return Zend_Db_Adapter
  *  @link http://framework.zend.com/manual/en/zend.db.html
  */
 protected function _initDb()
 {
     // Only attempt to cache the metadata if we have a cache available
     if (!is_null($this->_cache)) {
         try {
             Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
         } catch (Zend_Db_Table_Exception $e) {
             print $e->getMessage();
         }
     }
     $db = null;
     $dbPluginResource = $this->getPluginResource('db');
     if (!is_null($dbPluginResource)) {
         $db = $dbPluginResource->getDbAdapter();
         // Set the default fetch mode to object throughout the application
         $db->setFetchMode(Zend_Db::FETCH_OBJ);
         // Force the initial connection to handle error relating to caching etc.
         try {
             $db->getConnection();
         } catch (Zend_Db_Adapter_Exception $e) {
             // perhaps a failed login credential, or perhaps the RDBMS is not running
         } catch (Zend_Exception $e) {
             // perhaps factory() failed to load the specified Adapter class
         }
         Zend_Db_Table::setDefaultAdapter($db);
         Zend_Registry::set('db', $db);
     }
     return $db;
 }
开发者ID:rawatanil3,项目名称:Zend-Framework-Development-Project,代码行数:35,代码来源:Bootstrap.php

示例4: __construct

 public function __construct($addr = "127.0.0.1", $port = 8080)
 {
     $this->port = $port;
     $this->addr = $addr;
     $this->_startupSuperGlobal();
     // Setup basic stuff
     error_reporting(E_ALL & ~E_NOTICE);
     $base = realpath(dirname(__FILE__) . '/../');
     $paths = array('.', realpath($base . '/library'), get_include_path());
     $this->base = $base;
     // Setup autoloading ...
     set_include_path(implode(PATH_SEPARATOR, $paths));
     require_once 'Zend/Loader/Autoloader.php';
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->registerNamespace('EvHttp_');
     $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => realpath($base . '/application'), 'namespace' => '', 'resourceTypes' => array('model' => array('namespace' => 'Model', 'path' => 'models/'), 'form' => array('namespace' => 'Form', 'path' => 'forms/'))));
     // Load config
     $this->config = new Zend_Config_Ini($this->base . '/deploy/config.ini', 'default');
     Zend_Registry::set('config', $this->config);
     // Connect database
     $dbType = $this->config->database->type;
     $params = $this->config->database->toArray();
     $db = Zend_Db::factory($dbType, $params);
     Zend_Db_Table::setDefaultAdapter($db);
     Zend_Registry::set('db', $db);
     // Setup extended front controller.
     $this->controller = EvHttp_Controller_Front::getInstance();
     $this->controller->throwExceptions(true);
     $this->controller->returnResponse(true);
     $this->controller->setDefaultAction('index');
     $this->controller->setControllerDirectory(array('default' => $base . '/application/controllers'));
 }
开发者ID:dreamsxin,项目名称:Kellner,代码行数:32,代码来源:main.php

示例5: _initDatabase

 protected function _initDatabase()
 {
     $config = $this->getOptions();
     $db = Zend_Db::factory($config['resources']['db']['adapter'], $config['resources']['db']['params']);
     Zend_Db_Table::setDefaultAdapter($db);
     Zend_Registry::set("db", $db);
 }
开发者ID:MonCoder189,项目名称:Work,代码行数:7,代码来源:Bootstrap.php

示例6: _initConfig

 protected function _initConfig()
 {
     /* for local */
     $host = "localhost";
     $username = "root";
     $password = "";
     $dbname = "pocket_recruiter";
     /* for TEST Site */
     /*
     $host = "andybui.ipagemysql.com";
     $username = "adsis";
     $password = "ad5!5";        
     $dbname = "advantages_sis";
     */
     //--- db
     $db = Zend_Db::factory('MYSQLI', array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $dbname));
     Zend_Db_Table::setDefaultAdapter($db);
     Zend_Registry::set('DB', $db);
     Zend_Registry::set('DB_Info', array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $dbname));
     $sql = "SET NAMES utf8";
     $db->query($sql);
     if (!$db->isConnected()) {
         throw new PR_Exception('No Db connection', 1, PR_Exception::CRITICAL_ERROR);
     }
     //--- user_types
     $user_types = array(1 => "Super Admin", 2 => "School Admin", 3 => "Teacher", 4 => "Student");
     Zend_Registry::set('USER_TYPES', $user_types);
     //--- return
     return new Zend_Config($this->getOptions());
 }
开发者ID:andybui2014,项目名称:PocketRecuiter,代码行数:30,代码来源:Bootstrap.php

示例7: _initDB

 protected function _initDB()
 {
     $db = Zend_Db::factory('Pdo_Mysql', array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => 'xoso', 'charset' => 'utf8'));
     $db->setFetchMode(Zend_Db::FETCH_BOTH);
     Zend_Db_Table::setDefaultAdapter($db);
     return $db;
 }
开发者ID:kaibaok,项目名称:xs,代码行数:7,代码来源:Bootstrap.php

示例8: factory

	/**
	 * Create adapter
	 *
	 * @param string $adapterName database adapter name
	 * @param array $dbInfos database connection info
	 * @param bool $connect
	 * @return mixed (Piwik_Db_Adapter_Mysqli, Piwik_Db_Adapter_Pdo_Mysql, etc)
	 */
	public static function factory($adapterName, & $dbInfos, $connect = true)
	{
		if($connect)
		{
			if($dbInfos['port'][0] == '/')
			{
				$dbInfos['unix_socket'] = $dbInfos['port'];
				unset($dbInfos['host']);
				unset($dbInfos['port']);
			}

			// not used by Zend Framework
			unset($dbInfos['tables_prefix']);
			unset($dbInfos['adapter']);
			unset($dbInfos['schema']);
		}

		$className = self::getAdapterClassName($adapterName);
		Piwik_Loader::loadClass($className);
		$adapter = new $className($dbInfos);

		if($connect)
		{
			$adapter->getConnection();

			Zend_Db_Table::setDefaultAdapter($adapter);

			// we don't want the connection information to appear in the logs
			$adapter->resetConfig();
		}

		return $adapter;
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:41,代码来源:Adapter.php

示例9: _initDb

 /**
  * Init Db -- register db adapter
  */
 protected function _initDb()
 {
     $resource = $this->getPluginResource('db');
     Zend_Db_Table::setDefaultAdapter($resource->getDbAdapter());
     Zend_Registry::set('db', $resource->getDbAdapter());
     return $resource->getDbAdapter();
 }
开发者ID:rainmore,项目名称:Flickr-Gallery,代码行数:10,代码来源:Bootstrap.php

示例10: _database

 protected function _database()
 {
     $this->_db = Zend_Db::factory('Pdo_Mysql', array('host' => 'localhost', 'username' => 'test_bruno', 'password' => 'test_bruno', 'dbname' => 'test_bruno'));
     $this->_db->exec("SET NAMES 'utf8'");
     Zend_Db_Table::setDefaultAdapter($this->_db);
     return $this;
 }
开发者ID:houtsnip,项目名称:bruno_test,代码行数:7,代码来源:Bootstrap.php

示例11: loadDbAdapter

/**
 * Load database adapter.
 *
 * @param string $testConfigDir
 * @param string $dbType
 * @return Zend_Db_Adapter_Abstract
 * @throws Zend_Exception
 */
function loadDbAdapter($testConfigDir, $dbType)
{
    // create the lockfile for this dbType
    $dbConfigFile = $testConfigDir . '/' . $dbType . '.ini';
    $lockFile = $testConfigDir . '/lock.' . $dbType . '.ini';
    copy($dbConfigFile, $lockFile);
    // load the lockfile as the test dbConfig
    if (file_exists($lockFile)) {
        $configDatabase = new Zend_Config_Ini($lockFile, 'testing');
    } else {
        throw new Zend_Exception('Error, cannot load lockfile: ' . $lockFile);
    }
    if (empty($configDatabase->database->params->driver_options)) {
        $driverOptions = array();
    } else {
        $driverOptions = $configDatabase->database->params->driver_options->toArray();
    }
    $params = array('dbname' => $configDatabase->database->params->dbname, 'driver_options' => $driverOptions);
    if ($dbType != 'sqlite') {
        $params['username'] = $configDatabase->database->params->username;
        $params['password'] = $configDatabase->database->params->password;
        if (empty($configDatabase->database->params->unix_socket)) {
            $params['host'] = $configDatabase->database->params->host;
            $params['port'] = $configDatabase->database->params->port;
        } else {
            $params['unix_socket'] = $configDatabase->database->params->unix_socket;
        }
    }
    $db = Zend_Db::factory($configDatabase->database->adapter, $params);
    Zend_Db_Table::setDefaultAdapter($db);
    Zend_Registry::set('dbAdapter', $db);
    Zend_Registry::set('configDatabase', $configDatabase);
    return $db;
}
开发者ID:josephsnyder,项目名称:Midas,代码行数:42,代码来源:DatabaseSetup.php

示例12: _initDb

 protected function _initDb()
 {
     $resources = $this->getOption('resources');
     $dbConfig = $resources['db'];
     $db = \Zend_Db::factory($dbConfig['adapter'], array('host' => $dbConfig['params']['host'], 'username' => $dbConfig['params']['username'], 'password' => $dbConfig['params']['password'], 'dbname' => $dbConfig['params']['dbname'], 'adapterNamespace' => $dbConfig['params']['adapterNamespace']));
     \Zend_Db_Table::setDefaultAdapter($db);
 }
开发者ID:lukaszjankowski,项目名称:alchemy,代码行数:7,代码来源:Bootstrap.php

示例13: _initDb

 protected function _initDb()
 {
     if (isset($this->_config->db)) {
         try {
             $connections = new ArrayObject();
             foreach ($this->_config->db->connections as $dbId => $db) {
                 // using zend_db to setup connection but not using it for the app
                 $conn = Zend_Db::factory($db);
                 $connections->{$dbId} = $conn;
                 if ($dbId == @$this->_config->db->default) {
                     Zend_Db_Table::setDefaultAdapter($conn);
                     $this->_registry->set('db', $conn);
                     $this->_db = $conn;
                 }
             }
             $this->_registry->set('dbs', $connections);
         } catch (Exception $e) {
             $this->__throwError(new Exception('Cannot connect to required database; please try again later.'));
         }
     } else {
         $this->_db = null;
         $this->_dbs = array();
         $this->_registry->set('db', null);
     }
 }
开发者ID:ryanomite,项目名称:zapi,代码行数:25,代码来源:Bootstrap.php

示例14: factory

 /**
  * Create adapter
  *
  * @param string $adapterName database adapter name
  * @param array $dbInfos database connection info
  * @param bool $connect
  * @return Piwik_Db_Adapter_Interface
  */
 public static function factory($adapterName, &$dbInfos, $connect = true)
 {
     if ($connect) {
         if ($dbInfos['port'][0] == '/') {
             $dbInfos['unix_socket'] = $dbInfos['port'];
             unset($dbInfos['host']);
             unset($dbInfos['port']);
         }
         // not used by Zend Framework
         unset($dbInfos['tables_prefix']);
         unset($dbInfos['adapter']);
         unset($dbInfos['schema']);
     }
     $className = self::getAdapterClassName($adapterName);
     Piwik_Loader::loadClass($className);
     /*
      * 5.2.1 fixes various bugs with references that caused PDO_MYSQL getConnection()
      * to clobber $dbInfos. (#33282, #35106, #39944)
      */
     if (version_compare(PHP_VERSION, '5.2.1') < 0) {
         $adapter = new $className(array_map('trim', $dbInfos));
     } else {
         $adapter = new $className($dbInfos);
     }
     if ($connect) {
         $adapter->getConnection();
         Zend_Db_Table::setDefaultAdapter($adapter);
         // we don't want the connection information to appear in the logs
         $adapter->resetConfig();
     }
     return $adapter;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:40,代码来源:Adapter.php

示例15: init

 public function init()
 {
     $url = constant("APPLICATION_PATH") . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'application.ini';
     $dbconfig = new Zend_Config_Ini($url, "mysql");
     $db = Zend_Db::factory($dbconfig->db);
     $db->query('SET NAMES UTF8');
     Zend_Db_Table::setDefaultAdapter($db);
 }
开发者ID:yuxujian,项目名称:YuNote,代码行数:8,代码来源:BaseController.php


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