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