當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseManager::instance方法代碼示例

本文整理匯總了PHP中DatabaseManager::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseManager::instance方法的具體用法?PHP DatabaseManager::instance怎麽用?PHP DatabaseManager::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DatabaseManager的用法示例。


在下文中一共展示了DatabaseManager::instance方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkTable

 /**
  * Checks the currently existing table against the provided SQL schema in its associated file
  *
  * @param string $table The name of the table to check
  */
 private function checkTable($table)
 {
     // Get the fields from the existing table
     $fields = DatabaseManager::instance()->Table($table)->fetchAll(PDO::FETCH_COLUMN);
     // Get the table schema from the table structure in the file
     $schema = $this->grabTableInfo($table)[0];
     // Get the fields/columns from the schema - these will be used for comparison
     $columns = $schema->Columns();
     // Get the keys from the schema - used to determine if the key needs to be added
     $keys = $schema->Keys();
     $toAdd = [];
     // Compare the current table fields to the files fields
     for ($i = 0; $i < count($columns); $i++) {
         $add = true;
         // Get the current column name
         $colname = $columns[$i]['name'];
         // Check to see if the column name from the schema exists in the current table schema
         for ($j = 0; $j < count($fields); $j++) {
             // If the column does exist, skip it
             if ($colname == $fields[$j]) {
                 $add = false;
                 break;
             }
         }
         // If the column does not exist, add it to the list of columns that need to be re-added
         if ($add) {
             $toAdd[count($toAdd)] = $columns[$i];
         }
     }
     // If there are any columns to be added, add them.
     // This check might be redundant as technically it should not get here unless there are columns missing.
     if (count($toAdd) > 0) {
         $this->alterTable($table, $toAdd, $keys);
     }
 }
開發者ID:sam25,項目名稱:website,代碼行數:40,代碼來源:MigrationManager.php

示例2: getInstance

 public static function getInstance()
 {
     if (self::$instance == null) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
開發者ID:Birdimol,項目名稱:birdibeuk,代碼行數:8,代碼來源:DatabaseManager.php

示例3: getInstance

 private static function getInstance()
 {
     if (!self::$instance) {
         // If no instance then make one
         self::$instance = new self();
     }
     return self::$instance->dbConnection;
 }
開發者ID:sass-team,項目名稱:sass-app,代碼行數:8,代碼來源:DatabaseManager.class.php

示例4: resetInstance

 /**
  * Reset the internal static instance
  *
  * @return void
  */
 public static function resetInstance()
 {
     if (!self::$instance) {
         return;
     }
     self::$instance->reset();
     self::$instance = null;
 }
開發者ID:PermeAgility,項目名稱:FrameworkBenchmarks,代碼行數:13,代碼來源:DatabaseManager.php


注:本文中的DatabaseManager::instance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。