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


PHP DB::statement方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table($this->table)->truncate();
     parent::run();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
开发者ID:NathanCH,项目名称:urban-laravel,代码行数:12,代码来源:PermissionRoleTableSeeder.php

示例2: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('review_dog', function (Blueprint $table) {
         DB::statement('alter table review_dog modify walker_id int unsigned not null');
         $table->foreign('walker_id')->references('id')->on('walker');
     });
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:12,代码来源:2014_12_03_173126_add_foreign_key_review_dog_2.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     /**
      * Disable foreign key checks for this
      * connection before running seeders.
      */
     DB::statement('SET FOREIGN_KEY_CHECKS = 0;');
     $this->call('AlertsTableSeeder');
     $this->call('CheckCategoriesTableSeeder');
     $this->call('ChecksTableSeeder');
     $this->call('CheckResultsTableSeeder');
     $this->call('DatabaseTechnologiesTableSeeder');
     $this->call('EnvironmentsTableSeeder');
     $this->call('OperatingSystemsTableSeeder');
     $this->call('ReportLevelsTableSeeder');
     $this->call('ReportTypesTableSeeder');
     $this->call('TicketCategoriesTableSeeder');
     $this->call('TicketPrioritiesTableSeeder');
     $this->call('TicketTypesTableSeeder');
     /**
      * Will not seed clients, services, servers, and server check
      * results if this is the production environment.
      */
     if (getenv('APP_ENV') !== 'production') {
         $this->call('ClientsTableSeeder');
         $this->call('ServicesTableSeeder');
         $this->call('SitesTableSeeder');
         $this->call('ServersTableSeeder');
         $this->call('ServerCheckResultsTableSeeder');
     }
     // Reset foreign key checks.
     DB::statement('SET FOREIGN_KEY_CHECKS = 1;');
 }
开发者ID:ngaitanis,项目名称:dodona-dev,代码行数:39,代码来源:DatabaseSeeder.php

示例4: boot

 public static function boot()
 {
     self::creating(function ($custom_field) {
         if (in_array($custom_field->db_column_name(), \Schema::getColumnListing(\DB::getTablePrefix() . CustomField::$table_name))) {
             //field already exists when making a new custom field; fail.
             return false;
         }
         \Schema::table(\DB::getTablePrefix() . \App\Models\CustomField::$table_name, function ($table) use($custom_field) {
             $table->text($custom_field->db_column_name())->nullable();
         });
     });
     self::updating(function ($custom_field) {
         if ($custom_field->isDirty("name")) {
             if (in_array($custom_field->db_column_name(), \Schema::getColumnListing(CustomField::$table_name))) {
                 //field already exists when renaming a custom field
                 return false;
             }
             return \DB::statement("UPDATE " . CustomField::$table_name . " RENAME " . self::name_to_db_name($custom_field->get_original("name")) . " TO " . $custom_field->db_column_name());
         }
         return true;
     });
     self::deleting(function ($custom_field) {
         return \DB::statement("ALTER TABLE " . CustomField::$table_name . " DROP COLUMN " . $custom_field->db_column_name());
     });
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:25,代码来源:CustomField.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     DB::table('features')->truncate();
     /*
             Feature::create([
                 'href' => '/dm/home',
                 'btnclass' => 'btn-success',
                 'innerhtml' => '个人信息'
             ]);
     */
     Feature::create(['href' => '/patient', 'btnclass' => 'btn-primary', 'innerhtml' => '患者资料']);
     /*
             Feature::create([
                 'href' => '/case',
                 'btnclass' => 'btn-info',
                 'innerhtml' => '方案管理'
             ]);
     */
     Feature::create(['href' => '/bdata', 'btnclass' => 'btn-danger', 'innerhtml' => '血糖管理']);
     DB::table('hasfeatures')->truncate();
     Hasfeature::create(['user_id' => 2, 'feature_id' => 1]);
     Hasfeature::create(['user_id' => 2, 'feature_id' => 2]);
     /*
             Hasfeature::create([
                 'user_id' => 2,
                 'feature_id' => 3
             ]);
     */
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
开发者ID:purplebleed,项目名称:hljtnbdm,代码行数:38,代码来源:FeatureTableSeeder.php

示例6: run

 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     // Reset table
     DB::table('users')->truncate();
     // Reset table
     DB::table('user_details')->truncate();
     $admin_account = Config::get('cms::settings.admin_account');
     $admin_settings = array('role_id' => 1, 'lang' => Config::get('cms::settings.language'), 'editor' => 0, 'is_active' => 1);
     $admin_user = array_merge($admin_account, $admin_settings);
     $admin_user['password'] = Hash::make($admin_user['password']);
     $admin = User::create($admin_user);
     UserDetail::create(array('user_id' => $admin->id));
     // RANDOM 50 USERS
     // Faker data
     $faker = Faker\Factory::create();
     for ($i = 1; $i <= 50; $i++) {
         $user_settings = array('role_id' => 4, 'username' => $faker->username, 'email' => $faker->email, 'password' => Hash::make($faker->word), 'lang' => Config::get('cms::settings.language'), 'editor' => 0, 'is_active' => 1);
         $user = User::create($user_settings);
         $details = array('firstname' => $faker->firstname, 'lastname' => $faker->lastname, 'gender' => $faker->randomElement(array('m', 'f')), 'city' => $faker->city, 'bio' => $faker->text, 'birth_date' => $faker->date('Y-m-d', '-18 years'));
         $user->details()->create($details);
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
开发者ID:pongocms,项目名称:cms,代码行数:26,代码来源:UsersTableSeeder.php

示例7: up

 public function up()
 {
     $prefix = config('larablog.table.prefix');
     Schema::create($prefix . '_posts', function (Blueprint $t) {
         $t->increments('id')->unsigned();
         $t->string('identifier', 255)->index();
         $t->string('slug', 255)->unique()->index();
         $t->string('title', 255);
         $t->text('body');
         $t->text('meta');
         $t->enum('type', ['page', 'post', 'redirect'])->default('post');
         $t->enum('status', ['active', 'deleted'])->default('active')->index();
         $t->integer('views_count')->unsigned()->default(0)->index();
         $t->datetime('published_at')->index()->nullable();
         $t->timestamps();
         $t->index('created_at');
         $t->index('updated_at');
     });
     \DB::statement("ALTER TABLE " . $prefix . "_posts ADD FULLTEXT KEY " . $prefix . "_posts_title_body_fulltext (`title`, `body`)");
     Schema::create($prefix . '_tags', function (Blueprint $t) {
         $t->increments('id')->unsigned();
         $t->string('slug', 255)->unique()->index();
         $t->string('name', 255);
         $t->integer('posts_count')->unsigned()->default(0)->index();
         $t->timestamps();
         $t->index('created_at');
         $t->index('updated_at');
     });
     Schema::create($prefix . '_post_tag', function (Blueprint $t) {
         $t->integer('post_id')->unsigned()->index();
         $t->integer('tag_id')->unsigned()->index();
     });
 }
开发者ID:websanova,项目名称:larablog,代码行数:33,代码来源:0000_00_00_000000_create_larablog_blog_table.php

示例8: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Schema::dropIfExists('tbestadoanimal');
     //
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
开发者ID:wilmertri,项目名称:webcow,代码行数:12,代码来源:2014_10_31_231513_tbestadoanimal.php

示例9: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::statement('ALTER TABLE projects ALTER geo_lat SET DEFAULT 450');
     DB::statement('ALTER TABLE projects ALTER geo_lng SET DEFAULT 450');
     DB::statement('ALTER TABLE geocodes ALTER lat SET DEFAULT 450');
     DB::statement('ALTER TABLE geocodes ALTER lng SET DEFAULT 450');
 }
开发者ID:schlos,项目名称:GreenAlert,代码行数:12,代码来源:2014_12_13_212827_alter_projects_table_geo_defaults.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('estado')->insert(['nombre' => 'Bolivar']);
     DB::table('estado')->insert(['nombre' => 'Falcón']);
     DB::table('estado')->insert(['nombre' => 'Nueva Esparta']);
     DB::statement("INSERT INTO ciudades (`id`, `id_estado`, `nombre`, `id_capital`) VALUES\n                    (87, 1, 'Caicara del Orinoco', 0),\n                    (88, 1, 'Canaima', 0),\n                    (89, 1, 'Ciudad Bolívar', 1),\n                    (90, 1, 'Ciudad Piar', 0),\n                    (91, 1, 'El Callao', 0),\n                    (92, 1, 'El Dorado', 0),\n                    (93, 1, 'El Manteco', 0),\n                    (94, 1, 'El Palmar', 0),\n                    (95, 1, 'El Pao', 0),\n                    (96, 1, 'Guasipati', 0),\n                    (97, 1, 'Guri', 0),\n                    (98, 1, 'La Paragua', 0),\n                    (99, 1, 'Matanzas', 0),\n                    (151, 2, 'Adícora', 0),\n                    (152, 2, 'Boca de Aroa', 0),\n                    (153, 2, 'Cabure', 0),\n                    (154, 2, 'Capadare', 0),\n                    (155, 2, 'Capatárida', 0),\n                    (156, 2, 'Chichiriviche', 0),\n                    (157, 2, 'Churuguara', 0),\n                    (158, 2, 'Coro', 1),\n                    (159, 2, 'Cumarebo', 0),\n                    (160, 2, 'Dabajuro', 0),\n                    (161, 2, 'Judibana', 0),\n                    (162, 2, 'La Cruz de Taratara', 0),\n                    (163, 2, 'La Vela de Coro', 0),\n                    (164, 2, 'Los Taques', 0),\n                    (165, 2, 'Maparari', 0),\n                    (166, 2, 'Mene de Mauroa', 0),\n                    (167, 2, 'Mirimire', 0),\n                    (168, 2, 'Pedregal', 0),\n                    (169, 2, 'Píritu Falcón', 0),\n                    (170, 2, 'Pueblo Nuevo Falcón', 0),\n                    (171, 2, 'Puerto Cumarebo', 0),\n                    (172, 2, 'Punta Cardón', 0),\n                    (173, 2, 'Punto Fijo', 0),\n                    (174, 2, 'San Juan de Los Cayos', 0),\n                    (175, 2, 'San Luis', 0),\n                    (176, 2, 'Santa Ana Falcón', 0),\n                    (177, 2, 'Santa Cruz De Bucaral', 0),\n                    (178, 2, 'Tocopero', 0),\n                    (179, 2, 'Tocuyo de La Costa', 0),\n                    (180, 2, 'Tucacas', 0),\n                    (181, 2, 'Yaracal', 0),\n                    (321, 3, 'Altagracia', 0),\n                    (322, 3, 'Boca de Pozo', 0),\n                    (323, 3, 'Boca de Río', 0),\n                    (324, 3, 'El Espinal', 0),\n                    (325, 3, 'El Valle del Espíritu Santo', 0),\n                    (326, 3, 'El Yaque', 0),\n                    (327, 3, 'Juangriego', 0),\n                    (328, 3, 'La Asunción', 1),\n                    (329, 3, 'La Guardia', 0),\n                    (330, 3, 'Pampatar', 0),\n                    (331, 3, 'Porlamar', 0),\n                    (332, 3, 'Puerto Fermín', 0),\n                    (333, 3, 'Punta de Piedras', 0),\n                    (334, 3, 'San Francisco de Macanao', 0),\n                    (335, 3, 'San Juan Bautista', 0),\n                    (336, 3, 'San Pedro de Coche', 0),\n                    (337, 3, 'Santa Ana de Nueva Esparta', 0),\n                    (338, 3, 'Villa Rosa', 0)\n        ");
 }
开发者ID:paopudin,项目名称:tesis,代码行数:12,代码来源:estados.php

示例11: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0');
     Model::unguard();
     $this->call('UserSeeder');
     $this->call('UnitSeeder');
     $this->call('TagSeeder');
     // foods
     $this->call('FoodSeeder');
     $this->call('RecipeSeeder');
     $this->call('FoodEntrySeeder');
     //        $this->call('FoodRecipeSeeder');
     $this->call('RecipeMethodSeeder');
     //exercises
     $this->call('ExerciseSeriesSeeder');
     $this->call('ExerciseProgramSeeder');
     $this->call('ExerciseSeeder');
     $this->call('ExerciseEntrySeeder');
     $this->call('WorkoutSeeder');
     //weight
     $this->call('WeightSeeder');
     //journal
     $this->call('JournalSeeder');
     //tags
     $this->call('ActivitySeeder');
     $this->call('TimerSeeder');
     DB::statement('SET FOREIGN_KEY_CHECKS=1');
 }
开发者ID:JennySwift,项目名称:health-tracker,代码行数:33,代码来源:DatabaseSeeder.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement("SET foreign_key_checks = 0");
     Apartment::truncate();
     Apartment::create(['name' => 'Krushna Apartment', 'address_line1' => 'Yadav Nagar', 'address_line2' => 'Nr. Some Square', 'address_line3' => 'Jaiswal Restaurent', 'city' => 'Nagpur', 'state' => 'Maharashtra', 'country' => 'India', 'pincode' => '440026', 'lat' => '1.000', 'lng' => '2.000']);
     Apartment::create(['name' => 'Ravan Apartment', 'address_line1' => 'Gajanan Nagar', 'address_line2' => 'Nr. Some Square', 'address_line3' => 'Lagoo Restaurent', 'city' => 'Nagpur', 'state' => 'Maharashtra', 'country' => 'India', 'pincode' => '440032', 'lat' => '1.000', 'lng' => '2.000']);
 }
开发者ID:suchayj,项目名称:easymanage,代码行数:12,代码来源:ApartmentSeeder.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('answers')->truncate();
     $quiz = new Answer();
     $quiz->question_id = 1;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded answer 1';
     $quiz->is_right = 1;
     $quiz->save();
     $quiz = new Answer();
     $quiz->question_id = 1;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded answer 1';
     $quiz->is_right = 0;
     $quiz->save();
     $quiz = new Answer();
     $quiz->question_id = 2;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded answer 1';
     $quiz->is_right = 0;
     $quiz->save();
     $quiz = new Answer();
     $quiz->question_id = 2;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded answer 1';
     $quiz->is_right = 1;
     $quiz->save();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
开发者ID:siderate,项目名称:banana-api,代码行数:35,代码来源:AnswerTableSeeder.php

示例14: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('fbf_jobs', function (Blueprint $table) {
         $table->engine = 'MyISAM';
         // means you can't use foreign key constraints
         $table->increments('id');
         $table->string('title');
         $table->string('slug')->unique();
         $table->string('reference')->nullable();
         $table->string('location')->nullable();
         $table->enum('type', array('PERMANENT', 'TEMPORARY'))->nullable();
         $table->enum('time', array('FULL_TIME', 'PART_TIME'))->nullable();
         $table->string('salary_text')->nullable();
         $table->float('salary_from', 10, 2)->nullable();
         $table->float('salary_to', 10, 2)->nullable();
         $table->date('closing_date')->nullable();
         $table->text('description')->nullable();
         $table->text('search_extra')->nullable();
         $table->text('meta_description')->nullable();
         $table->text('meta_keywords')->nullable();
         $table->enum('status', array('DRAFT', 'APPROVED'))->default('DRAFT');
         $table->dateTime('published_date');
         $table->timestamps();
         $table->softDeletes();
     });
     DB::statement('ALTER TABLE fbf_jobs ADD FULLTEXT search(title,description,reference,location,search_extra,meta_description,meta_keywords)');
 }
开发者ID:yudancuk,项目名称:Laravel-Jobs,代码行数:32,代码来源:2013_11_15_214339_create_jobs_table.php

示例15: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     // drop table
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Schema::dropIfExists('reports');
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
开发者ID:michaelharrisonroth,项目名称:vendorify,代码行数:12,代码来源:2015_09_03_185202_create_reports_table.php


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