当前位置: 首页>>代码示例>>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;未经允许,请勿转载。