コード例 #1
0
ファイル: demo.php プロジェクト: bogus115/kohana-fans-cn
 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
0
ファイル: DBManager.class.php プロジェクト: ratbird/hope
 /**
  * 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
0
ファイル: DBManager.php プロジェクト: Abhishek627/crux
 /**
  * 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;
 }