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


PHP Manager::schema方法代碼示例

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


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

示例1: TableExists

 /**
  * Returns true if the specified table exists in the database.
  *
  * @param $table
  *
  * @return bool
  */
 public function TableExists($table)
 {
     if ($this->capsule->schema()->hasTable($table)) {
         return true;
     }
     return false;
 }
開發者ID:CrashfortStudios,項目名稱:MusicCommerce,代碼行數:14,代碼來源:Manager.php

示例2: createSchema

 /**
  * Create Schema
  *
  * @return AdapterInterface
  */
 public function createSchema()
 {
     /* @var \Illuminate\Database\Schema\Blueprint $table */
     $this->adapter->schema()->create($this->tableName, function ($table) {
         $table->string('version');
     });
 }
開發者ID:edisonnica,項目名稱:phpmig,代碼行數:12,代碼來源:Database.php

示例3: setupBeforeClass

 public static function setupBeforeClass()
 {
     $db = new DB();
     $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
     $db->setAsGlobal();
     $db->bootEloquent();
     $db->schema()->create('voucher_campaigns', function ($table) {
         $table->increments('id');
         $table->timestamps();
         $table->string('name');
         $table->string('brand');
         $table->string('urn')->unique();
         $table->integer('expiry_limit')->default('14');
         $table->boolean('is_active')->default('1');
     });
     $db->schema()->create('voucher_entries', function ($table) {
         $table->increments('id');
         $table->timestamps();
         $table->string('hash')->unique();
         $table->integer('campaign_id');
         $table->boolean('is_redeemed')->default('0');
         $table->datetime('redeemed_at')->default('0000-00-00 00:00:00');
         $table->boolean('is_expired')->default('0');
         $table->datetime('expired_at')->default('0000-00-00 00:00:00');
         $table->boolean('is_valid')->default('1');
     });
     parent::setupBeforeClass();
     static::$fm->seed(5, 'Fastwebmedia\\LaravelVouchering\\Models\\Campaign');
     static::$fm->seed(5, 'Fastwebmedia\\LaravelVouchering\\Models\\Voucher');
 }
開發者ID:fastwebmedia,項目名稱:laravel-vouchering,代碼行數:30,代碼來源:VoucherFactoryTest.php

示例4: init

 public function init()
 {
     $this->capsule = new Capsule();
     $this->capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'port' => DB_PORT, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci']);
     $this->capsule->bootEloquent();
     $this->capsule->setAsGlobal();
     $this->schema = $this->capsule->schema();
 }
開發者ID:joppuyo,項目名稱:EloquentMigrationsUsingPhinx,代碼行數:8,代碼來源:Migration.php

示例5: init

 /**
  * Init the migration
  */
 public function init()
 {
     //Get the Container
     $container = $this->getContainer();
     //Get Eloquent capsule
     $this->capsule = $container['db'];
     //Get schema builder instance
     $this->schema = $this->capsule->schema();
 }
開發者ID:AshniSukhoo,項目名稱:UOM_connect,代碼行數:12,代碼來源:20160229181425_CreateStudentCourseFacultyTable.php

示例6: createMigrationHistoryTable

 /**
  * Creates the migration history table.
  */
 protected function createMigrationHistoryTable()
 {
     $tableName = $this->migrationTable;
     $this->stdout("Creating migration history table \"{$tableName}\"...", Console::FG_YELLOW);
     $this->db->schema()->create($this->migrationTable, function (Blueprint $table) {
         $table->string('version', 180);
         $table->primary('version');
         $table->integer('apply_time');
     });
     $this->addMigrationHistory(self::BASE_MIGRATION);
     $this->stdout("Done.\n", Console::FG_GREEN);
 }
開發者ID:lordthorzonus,項目名稱:yii2-eloquent,代碼行數:15,代碼來源:MigrateController.php

示例7: createAndSeedOrdersTable

 /**
  * Creates and seeds the order table.
  */
 protected function createAndSeedOrdersTable()
 {
     /*
      * @var $db Manager
      */
     $this->db = Yii::$app->db;
     $this->db->schema()->create('order', function ($table) {
         $table->increments('id');
         $table->string('name')->unique();
         $table->timestamps();
     });
     Order::create(['name' => 'Test address']);
     Order::create(['name' => 'Another test Address']);
 }
開發者ID:lordthorzonus,項目名稱:yii2-eloquent,代碼行數:17,代碼來源:Yii2EloquentTest.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $this->mockWebApplication();
     $this->db = Yii::$app->db;
     $this->db->schema()->dropIfExists('order');
     $this->db->schema()->create('order', function (Blueprint $table) {
         $table->increments('id');
         $table->string('address');
         $table->timestamps();
     });
     $this->unloadFixtures();
     $this->loadFixtures();
 }
開發者ID:lordthorzonus,項目名稱:yii2-eloquent,代碼行數:14,代碼來源:EloquentFixtureTest.php

示例9: migrateTables

 protected function migrateTables()
 {
     DB::schema()->create('posts', function ($table) {
         $table->increments('id');
         $table->integer('author_id')->unsigned();
         $table->string('title');
         $table->timestamps();
     });
     DB::schema()->create('comments', function ($table) {
         $table->increments('id');
         $table->integer('post_id')->unsigned();
         $table->string('body');
         $table->timestamps();
     });
     DB::schema()->create('people', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
     });
     DB::schema()->create('messages', function ($table) {
         $table->increments('id');
         $table->integer('sender_id')->unsigned();
         $table->integer('receiver_id')->unsigned();
         $table->string('contents');
         $table->timestamps();
     });
 }
開發者ID:Rotron,項目名稱:laravel5-shop,代碼行數:27,代碼來源:FactoryTest.php

示例10: runMigrations

 /**
  * command migrate
  */
 private function runMigrations()
 {
     $files = glob($this->getMigrationPath() . '/*.php');
     if (!Capsule::schema()->hasTable('migrations')) {
         Capsule::schema()->create('migrations', function ($table) {
             $table->string('migration');
             $table->integer('batch');
         });
     }
     $migrations = Migration::all();
     foreach ($migrations as $migration) {
         $filename = $this->getMigrationPath() . '/' . $migration->migration . '.php';
         if (in_array($filename, $files)) {
             $key = array_keys($files, $filename);
             unset($files[$key[0]]);
         }
     }
     $batch = Migration::all()->max('batch') + 1;
     foreach ($files as $file) {
         require_once $file;
         $filename = basename($file, '.php');
         $class = substr($filename, 18);
         $migration = new $class();
         $migration->up();
         Migration::create(array('migration' => $filename, 'batch' => $batch));
         $this->line("<success>File \"{$filename}.php\" processed</success>\n");
     }
 }
開發者ID:wu3rstle,項目名稱:slimtwig,代碼行數:31,代碼來源:Db.php

示例11: migrateTables

 /**
  * Migrates the tables required for testing.
  */
 protected function migrateTables()
 {
     DB::schema()->create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email');
         $table->timestamps();
     });
     DB::schema()->create('posts', function (Blueprint $table) {
         $table->increments('id');
         $table->string('title');
         $table->text('body');
         $table->unsignedInteger('user_id')->index();
         $table->timestamps();
     });
     DB::schema()->create('tags', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
     });
     DB::schema()->create('post_tag', function (Blueprint $table) {
         $table->unsignedInteger('tag_id')->index();
         $table->unsignedInteger('post_id')->index();
     });
     DB::schema()->create('categories', function (Blueprint $table) {
         $table->increments('id');
         $table->string('title');
         $table->text('description')->nullable();
         $table->timestamps();
     });
 }
開發者ID:logaretm,項目名稱:transformers,代碼行數:34,代碼來源:TestCase.php

示例12: createTables

 public function createTables()
 {
     Capsule::schema()->create('routes', function ($table) {
         $table->increments('id');
         $table->string('name')->nullable();
     });
     Capsule::schema()->create('methods', function ($table) {
         $table->increments('id');
         $table->string('tags');
         $table->enum('method', ['GET', 'POST', 'PUT', 'DELETE']);
         $table->text('description')->nullable();
         $table->integer('route_id')->unsigned()->index();
         $table->foreign('route_id')->references('id')->on('routes')->onDelete('cascade');
     });
     Capsule::schema()->create('parameters', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->enum('in', ['formData', 'path']);
         $table->text('description')->nullable();
         $table->boolean('required');
         $table->enum('type', ['string', 'file']);
         $table->integer('method_id')->unsigned()->index();
         $table->foreign('method_id')->references('id')->on('methods')->onDelete('cascade');
     });
 }
開發者ID:ritesrnjn,項目名稱:api_docs,代碼行數:25,代碼來源:migrate.php

示例13: createTables

 protected function createTables()
 {
     Manager::schema()->create('conv_users', function ($table) {
         $table->integer('conv_id')->nullable();
         $table->integer('user_id')->nullable();
         $table->primary(array('conv_id', 'user_id'));
     });
     Manager::schema()->create('conversations', function ($table) {
         $table->increments('id');
         $table->softDeletes();
         $table->timestamps();
     });
     Manager::schema()->create('messages', function ($table) {
         $table->increments('id');
         $table->integer('sender_id');
         $table->integer('conv_id');
         $table->text('content');
         $table->timestamps();
         $table->index('sender_id');
         $table->index('conv_id');
     });
     Manager::schema()->create('messages_status', function ($table) {
         $table->increments('id');
         $table->integer('user_id');
         $table->integer('msg_id');
         $table->boolean('self');
         $table->integer('status');
         $table->index('msg_id');
     });
 }
開發者ID:pnagaraju25,項目名稱:tbmsg,代碼行數:30,代碼來源:TestCaseDb.php

示例14: migration

 /**
  * To Perform migration to ensure the table and its properties
  * are up-to-date
  *
  */
 public static function migration()
 {
     $tables = Migration::tables();
     // Simple Filters.
     if (!isset($tables)) {
         return false;
     }
     foreach ($tables as $key => $value) {
         if (empty($value) || is_null($value) || !isset($value)) {
             continue;
         }
         loop:
         if (Capsule::Schema()->hasTable($key)) {
             foreach ($value as $column => $datatype) {
                 if (!Capsule::Schema()->hasColumn($key, $column)) {
                     //Assign the Name and Datatype for temporary access
                     self::$columns['name'] = $column;
                     self::$columns['datatype'] = $datatype;
                     Capsule::Schema()->table($key, function ($table) {
                         $column = self::$columns['name'];
                         $datatype = self::$columns['datatype'];
                         $table->{$datatype}($column)->after('id');
                     });
                 }
             }
         } else {
             Capsule::schema()->create($key, function ($table) {
                 $table->increments('id');
                 $table->timestamps();
             });
             goto loop;
         }
     }
 }
開發者ID:shankarbala33,項目名稱:php_migration,代碼行數:39,代碼來源:init.php

示例15: migrateTables

 protected function migrateTables()
 {
     DB::schema()->create('models', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
     });
 }
開發者ID:joeriaben,項目名稱:bladecache,代碼行數:8,代碼來源:TestCase.php


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