当前位置: 首页>>代码示例>>PHP>>正文


PHP Schema::getConnection方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Schema::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::getConnection方法的具体用法?PHP Schema::getConnection怎么用?PHP Schema::getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Schema的用法示例。


在下文中一共展示了Schema::getConnection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->confirm("Clear database? [Yes|no]", "Yes")) {
         $this->info('Clear database start');
         if (config('database.default') == 'mysql') {
             DB::statement('SET FOREIGN_KEY_CHECKS=0');
         } else {
             if (config('database.default') == 'sqlite') {
                 DB::statement('PRAGMA foreign_keys = OFF');
             }
         }
         $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
         foreach ($tableNames as $v) {
             Schema::drop($v);
             $this->info('Dropped: ' . $v);
         }
         $this->info('Clear database end');
         if (config('database.default') == 'mysql') {
             DB::statement('SET FOREIGN_KEY_CHECKS=1');
         } else {
             if (config('database.default') == 'sqlite') {
                 DB::statement('PRAGMA foreign_keys = ON');
             }
         }
     }
 }
开发者ID:Mrzhanglu,项目名称:ForoneAdministrator,代码行数:31,代码来源:ClearDatabase.php

示例2: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Oh my word! Cant rename any columns in a table that has an
     // enum. o_0
     //
     // Apply the hacky workaround seen here:
     //  https://github.com/laravel/framework/issues/1186#issuecomment-248853309
     Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     // Define the tables and columns that need to be changed
     $integer_tables_and_columns = ['character_bookmarks' => ['itemID'], 'eve_conquerable_station_lists' => ['stationID'], 'character_character_sheets' => ['homeStationID'], 'character_contact_lists' => ['labelMask'], 'character_contact_list_labels' => ['labelID'], 'character_contact_list_alliances' => ['labelMask'], 'character_contact_list_alliance_labels' => ['labelID'], 'character_contact_list_corporates' => ['labelMask'], 'character_contact_list_corporate_labels' => ['labelID'], 'character_contracts' => ['startStationID', 'endStationID'], 'character_industry_jobs' => ['stationID', 'blueprintLocationID', 'outputLocationID'], 'character_market_orders' => ['stationID'], 'character_wallet_journals' => ['argID1'], 'character_wallet_transactions' => ['stationID'], 'corporation_bookmarks' => ['itemID'], 'corporation_contact_list_labels' => ['labelID'], 'corporation_contact_lists' => ['labelMask'], 'corporation_contact_list_alliances' => ['labelMask'], 'corporation_contact_list_alliance_labels' => ['labelID'], 'corporation_contracts' => ['startStationID', 'endStationID'], 'corporation_member_securities' => ['roleID'], 'corporation_sheets' => ['stationID'], 'corporation_industry_jobs' => ['stationID', 'blueprintLocationID', 'outputLocationID'], 'corporation_market_orders' => ['stationID'], 'corporation_wallet_journals' => ['argID1'], 'corporation_wallet_transactions' => ['stationID']];
     // Loop over the changes defined in the above array.
     foreach ($integer_tables_and_columns as $table => $columns) {
         Schema::table($table, function (Blueprint $table) use($columns) {
             // Loop over the columns that are passed in and change them
             foreach ($columns as $column) {
                 $table->bigInteger($column)->change();
             }
         });
     }
     // Fix some Wallet values for the industry jobs tables.
     Schema::table('character_industry_jobs', function (Blueprint $table) {
         $table->decimal('cost', 30, 2)->change();
     });
     Schema::table('corporation_industry_jobs', function (Blueprint $table) {
         $table->decimal('cost', 30, 2)->change();
     });
 }
开发者ID:eveseat,项目名称:eveapi,代码行数:32,代码来源:2016_10_20_070644_fix_strictmode_integer_sizes.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $this->info('Database Backup Start...');
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $tableName) {
         Iseed::generateSeed($tableName);
         $this->info('Seeded: ' . $tableName);
     }
     $this->info('Database Backup End...');
 }
开发者ID:RedStarGroup,项目名称:ForoneAdmin,代码行数:16,代码来源:Backup.php

示例4: __construct

 public function __construct($tableName)
 {
     $this->tableName = $tableName;
     $this->doctrineSchemaManager = Schema::getConnection()->getDoctrineSchemaManager();
     $this->queryBuilder = DB::table($tableName);
 }
开发者ID:howtomakeaturn,项目名称:csvdumper,代码行数:6,代码来源:CSVDumper.php

示例5: getColumns

 public function getColumns($table)
 {
     $columns = Schema::getColumnListing(str_replace(Schema::getConnection()->getTablePrefix(), '', $table));
     return json_encode($columns);
 }
开发者ID:bloveless,项目名称:migrator-module,代码行数:5,代码来源:ColumnMigratorController.php


注:本文中的Illuminate\Support\Facades\Schema::getConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。