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


PHP Schema::getConnection方法代码示例

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


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

示例1: migrate

 /**
  * Resets the database and install the migration table.
  *
  * @return void
  */
 protected function migrate()
 {
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $table) {
         Schema::drop($table);
     }
     $this->app['Illuminate\\Contracts\\Console\\Kernel']->call('migrate:install', ['--env' => 'testing']);
 }
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:13,代码来源:TestCase.php

示例2: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('enum', 'string');
     Schema::table('assets', function ($table) {
         $table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change();
     });
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:13,代码来源:2016_08_30_084634_make_purchase_cost_nullable.php

示例3: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('goods', function (Blueprint $table) {
         $table->dropColumn('capsule_unit');
     });
     $table = Schema::getConnection()->getTablePrefix() . 'good_log';
     DB::statement("ALTER TABLE `" . $table . "` MODIFY COLUMN  `status`  ENUM('purchase', 'new', 'picking' , 'price', 'edit', 'damage', 'replacement', 'allocation', 'empty');");
 }
开发者ID:huanghua581,项目名称:erp,代码行数:13,代码来源:2014_06_09_203000_add_capsule_to_goods_table.php

示例4: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $grammar = Schema::getConnection()->getSchemaGrammar();
     if ($grammar instanceof \Illuminate\Database\Schema\Grammars\MySqlGrammar) {
         Schema::table('GDN_Discussion', function ($table) {
             $table->dropIndex('search');
         });
     }
     Schema::drop('GDN_Discussion');
 }
开发者ID:bishopb,项目名称:laravel-forums,代码行数:15,代码来源:2014_09_23_194713_create_GDN_Discussion_table.php

示例5: cleanDatabase

 /**
  * Clean out the database for a new seed generation.
  */
 private function cleanDatabase()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0');
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $name) {
         //if you don't want to truncate migrations
         if ($name == 'migrations') {
             continue;
         }
         DB::table($name)->truncate();
     }
     DB::statement('SET FOREIGN_KEY_CHECKS=1');
 }
开发者ID:noikiy,项目名称:laravel-chat-example,代码行数:16,代码来源:DatabaseSeeder.php

示例6: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     \Schema::create($this->table, function (Blueprint $table) {
         $table->increments('meta_id');
         $table->string('meta_key');
         $table->longText('meta_value');
         $table->string('meta_type')->default('string');
         $table->morphs('metable');
         $table->index('meta_key');
         // Laravel doesn't handle index length, so we need raw statement for this one
         \Schema::getConnection()->statement('create index meta_attributes_index_value on meta_attributes (meta_key, meta_value(20))');
     });
 }
开发者ID:boukeversteegh,项目名称:eloquence,代码行数:18,代码来源:CreateMetaAttributesTable.php

示例7: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('people', function (Blueprint $table) {
         // Credit: https://github.com/laravel/framework/issues/3253#issuecomment-51961561
         $conn = Schema::getConnection();
         $dbSchemaManager = $conn->getDoctrineSchemaManager();
         $doctrineTable = $dbSchemaManager->listTableDetails('people');
         if ($doctrineTable->hasIndex('people_email_unique')) {
             $table->dropUnique('people_email_unique');
         }
         $table->dropUnique('deleted_at');
         $table->unique(['email', 'deleted_at']);
     });
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:19,代码来源:2016_10_11_133800_fix_people_indexes.php

示例8: up

 /**
  * Add the seeded data.
  */
 public function up()
 {
     // we will have some crazy ID values, cajole MySQL into accepting them
     $grammar = Schema::getConnection()->getSchemaGrammar();
     if ($grammar instanceof \Illuminate\Database\Schema\Grammars\MySqlGrammar) {
         DB::statement('SET SESSION SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";');
     }
     // do the seeding
     DB::beginTransaction();
     foreach ($this->getSeedData() as $table => $rows) {
         // Note: each row may have different columns: can't use bulk insert
         foreach ($rows as $row) {
             $this->insertRow($table, $row);
         }
     }
     DB::commit();
 }
开发者ID:bishopb,项目名称:laravel-forums,代码行数:20,代码来源:2014_09_23_194714_seed_base_vanilla_tables.php

示例9: emptyTables

 private function emptyTables()
 {
     if (substr_count(get_class(DB::connection()), 'MySql') > 0) {
         DB::statement('SET FOREIGN_KEY_CHECKS=0');
     }
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $name) {
         //if you don't want to truncate migrations
         if ($name == 'migrations') {
             continue;
         }
         DB::table($name)->truncate();
     }
     if (substr_count(get_class(DB::connection()), 'MySql') > 0) {
         DB::statement('SET FOREIGN_KEY_CHECKS=1');
     }
 }
开发者ID:slice-beans,项目名称:cqs-framework,代码行数:17,代码来源:DatabaseSeeder.php

示例10: testSetUp

 /**
  * Tests to make sure our testing environment is set up correctly
  */
 public function testSetUp()
 {
     // make sure tests are working
     $this->assertTrue(true);
     // make sure Sentry is loaded and facade works
     $this->assertInstanceOf('Cartalyst\\Sentry\\Sentry', $this->app['sentry']);
     // verify that we have a database connection
     $this->assertInstanceOf('Illuminate\\Database\\Connection', Schema::getConnection());
     // test that our database exists and has tables created in migrations
     $this->assertTrue(Schema::hasTable('migrations'));
     $this->assertTrue(Schema::hasTable('users'));
     $this->assertTrue(Schema::hasTable('foos'));
     $this->assertTrue(Schema::hasTable('bars'));
     $this->assertTrue(Schema::hasTable('bazes'));
     // test that the data we entered is loaded
     // check to see that our testing models were loaded
     $this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Foo'));
     $this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Bar'));
     $this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Baz'));
 }
开发者ID:morphatic,项目名称:snapi,代码行数:23,代码来源:SnAPITest.php

示例11: dropTables

 /**
  * Drop all the tables in the database
  */
 public function dropTables()
 {
     $all_tables = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     \DB::statement("SET foreign_key_checks = 0");
     foreach ($all_tables as $table) {
         \DB::statement('DROP TABLE IF EXISTS ' . $table);
     }
 }
开发者ID:jrafaelca,项目名称:Doptor,代码行数:11,代码来源:Synchronize.php

示例12: up

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
class ChangeProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('products', function ($table) {
            $table->integer('subindustry_id')->unsigned()->nullable()->change();
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('products', function ($table) {
            $table->integer('subindustry_id')->unsigned()->change();
        });
    }
}
开发者ID:sagaciresearch,项目名称:adtracking,代码行数:31,代码来源:2016_04_06_132243_change_products_table.php

示例13: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $table = Schema::getConnection()->getTablePrefix() . 'good_log';
     DB::statement("ALTER TABLE `" . $table . "` MODIFY COLUMN  `status`  ENUM('purchase', 'new', 'picking' , 'price', 'edit', 'damage', 'replacement');");
 }
开发者ID:huanghua581,项目名称:erp,代码行数:10,代码来源:2014_05_08_143850_add_status_to_good_log_table.php


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