本文整理匯總了PHP中DBManager::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBManager::instance方法的具體用法?PHP DBManager::instance怎麽用?PHP DBManager::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBManager
的用法示例。
在下文中一共展示了DBManager::instance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action_index
public function action_index()
{
//$db = new Database;
$dbmanager = DBManager::instance();
//echo $dbmanager->get_version();
//echo $dbmanager->total_tables();
// List tables
//echo '==================<br />List tables<br />==================';
//$tables = $dbmanager->list_tables();
//echo Kohana::debug($tables);
// Only list name of tables
//echo '==================<br />Only list name of tables<br />==================';
//$table_name = $db->list_tables();
//echo Kohana::debug($table_name);
// List backup files
//echo '==================<br />List backup files<br />==================';
//echo Kohana::debug($dbmanager->list_backfiles());
// Optimize Tables
//echo '==================<br />Optimize Tables<br />==================<br />';
//$result = $dbmanager->optimize_tables($table_name);
//if ( !empty($result) )
// echo $result;
//else
// echo '全部優化完畢';
echo '==================<br />Backup Tables<br />==================<br />';
echo 'Next Backup time: ' . $dbmanager->next_backup_time() . '<br />';
echo Kohana::debug($dbmanager->backup_db());
// Download backup file. $filename = '1234567890_-_database.sql'
// $dbmanager->download_backup($filename);
// Delete backup file. $filename = '1234567890_-_database.sql'
// $dbmanager->delete_backup($filename);
// Display the demo page
//$this->template->title = 'Database Manager';
//$this->template->content = ;
}
示例2: getInstance
/**
* This method returns the singleton instance of this class.
*
* @return DBManager the singleton instance
*/
public static function getInstance()
{
if (is_null(DBManager::$instance)) {
DBManager::$instance = new DBManager();
}
return DBManager::$instance;
}
示例3: getInstance
/**
* Gives PDO database instance. Singleton implementation
*
* @throws PDOException
* @return PDO
*/
public static function getInstance()
{
if (!self::$instance instanceof PDO) {
$dsn = self::getMysqlDSN();
$host = Configuration::get(Configuration::DB_HOST);
$user = Configuration::get(Configuration::DB_USER);
$pass = Configuration::get(Configuration::DB_PASS);
$name = Configuration::get(Configuration::DB_NAME);
try {
Logger::getLogger()->LogDebug('New DB Instance created');
self::$instance = new PDO($dsn, $user, $pass);
self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
Logger::getLogger()->LogFatal($e->getMessage());
}
}
return self::$instance;
}