本文整理匯總了PHP中Zend_Db_Adapter_Abstract::isConnected方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Db_Adapter_Abstract::isConnected方法的具體用法?PHP Zend_Db_Adapter_Abstract::isConnected怎麽用?PHP Zend_Db_Adapter_Abstract::isConnected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Db_Adapter_Abstract
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Abstract::isConnected方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCurrentSchemaVersion
public function getCurrentSchemaVersion()
{
if (empty($this->_module)) {
throw new FFR_Exception('Module was empty. A module must be set.');
}
$cache = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache')->getManager()->getCache('database');
if (!($version = $cache->load($this->_module . 'Version'))) {
// Ensure we have valid connection to the database
if (!$this->_db->isConnected()) {
$this->_db->getServerVersion();
}
$sql = 'SELECT schema_version FROM ' . $this->_schemaVersionTable . ' WHERE schema_module = "' . $this->_module . '"';
$version = null;
try {
$version = $this->_db->fetchOne($sql);
} catch (Zend_Db_Exception $e) {
// exception means that the schema version table doesn't exist, so create it
$createSql = "CREATE TABLE {$this->_schemaVersionTable} (\n schema_id INT NOT NULL AUTO_INCREMENT,\n schema_version INT NOT NULL,\n schema_module VARCHAR(50),\n PRIMARY KEY (schema_id)\n )";
$this->_db->query($createSql);
}
// There isn't a version record so lets make one
if ($version === null || $version === false) {
$insertSql = "INSERT {$this->_schemaVersionTable} SET schema_version = 0," . ' schema_module = "' . $this->_module . '"';
$this->_db->query($insertSql);
$version = $this->_db->fetchOne($sql);
}
$cache->save($version, $this->_module . 'Version', array('schemaVersion'));
}
return $version;
}
示例2: __construct
public function __construct(Zend_Db_Adapter_Abstract $adapter, $options = array())
{
if (!$adapter->isConnected()) {
throw new Khcn_Exception('Adapter not connected');
}
$this->_adapter = $adapter;
if (is_array($options)) {
$this->setOptions($options);
}
}
示例3: getCurrentSchemaVersion
function getCurrentSchemaVersion()
{
// Ensure we have valid connection to the database
if (!$this->_db->isConnected()) {
$this->_db->getServerVersion();
}
$schemaVersionTableName = $this->getPrefixedSchemaVersionTableName();
$sql = "SELECT version FROM " . $schemaVersionTableName;
try {
$version = $this->_db->fetchOne($sql);
} catch (Exception $e) {
// exception means that the schema version table doesn't exist, so create it
$createSql = "CREATE TABLE {$schemaVersionTableName} ( \n version bigint NOT NULL,\n PRIMARY KEY (version)\n )";
$this->_db->query($createSql);
$insertSql = "INSERT INTO {$schemaVersionTableName} (version) VALUES (0)";
$this->_db->query($insertSql);
$version = $this->_db->fetchOne($sql);
}
return $version;
}
示例4: openConnection
public function openConnection()
{
if (!self::$dbAdapter) {
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$options = $bootstrap->getOptions();
try {
self::$dbAdapter = Zend_Db::factory($options['database']['adapter'], ['host' => $options['database']['params']['host'], 'username' => $options['database']['params']['username'], 'password' => $options['database']['params']['password'], 'dbname' => $options['database']['params']['dbname']]);
if (!self::$dbAdapter->isConnected()) {
//$this->closeConnection();
//throw new PDOException;
}
} catch (PDOException $pdo) {
die('<div class="big huge">
<span class="icon-warning-sign"></span>
<h1>feader reached the maximum limit of parallel users</h1>
<h2>We\'re working hard to fix this. Please come back later!</h2>
</div>');
}
}
$this->_db = self::$dbAdapter;
$this->_db->query('SET NAMES utf8');
}
示例5: isConnected
/**
* Test if a connection is active
*
* @return boolean
*/
public function isConnected()
{
return $this->_adapter->isConnected();
}