本文整理汇总了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();
}