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


PHP Manager::insert方法代码示例

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


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

示例1: invite

 /**
  * Invite a new player to guild
  *
  * @return void
  */
 public function invite(Character $player, $gid)
 {
     Capsule::insert('INSERT INTO `guild_invites` (`player_id`, `guild_id`) VALUES (?, ?)', [$player->id, $gid]);
 }
开发者ID:Codex-NG,项目名称:cornexaac,代码行数:9,代码来源:Guild.php

示例2: setBonusAttribute

 public function setBonusAttribute($value)
 {
     DB::delete('delete from t_event_bonuses where event_id = ? and player_id = ?', [$this->event->id, $this->player->id]);
     if ($value && $value != 'null') {
         DB::insert('insert into t_event_bonuses (event_id, player_id, bonus_id) values (?, ?, ?)', [$this->event->id, $this->player->id, $value]);
     }
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:7,代码来源:Score.php

示例3: testRawQueries

 public function testRawQueries()
 {
     // Insert
     $inserted = Capsule::insert('INSERT INTO articles (title) VALUES (:title)', ['title' => static::ARTICLE_TITLE]);
     $this->assertTrue($inserted);
     // Last Insert ID
     $id = Capsule::connection()->getPdo()->lastInsertId();
     $this->assertEquals(1, $id);
     // Select
     $articles = Capsule::select('SELECT * FROM articles WHERE id = ?', [$id]);
     $this->assertCount(1, $articles);
     $this->assertEquals($articles[0]->title, static::ARTICLE_TITLE);
     // Delete
     $deleted = Capsule::delete('DELETE FROM articles WHERE id = ?', [$id]);
     $this->assertEquals(1, $deleted);
     // Count
     $count = Capsule::selectOne('SELECT COUNT(*) as nb FROM articles');
     $this->assertEquals(0, $count->nb);
 }
开发者ID:jguyomard,项目名称:silex-capsule-eloquent,代码行数:19,代码来源:CapsuleServiceProviderTest.php

示例4: seedUsersTable

 /**
  * Create some users for the tests to use
  */
 private function seedUsersTable()
 {
     DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, name, email, created_at, updated_at) VALUES (?, ?, ?, datetime(), datetime())', [1, 'Chris Gmyr', 'chris@test.com']);
     DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, name, email, created_at, updated_at) VALUES (?, ?, ?, datetime(), datetime())', [2, 'Adam Wathan', 'adam@test.com']);
     DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, name, email, created_at, updated_at) VALUES (?, ?, ?, datetime(), datetime())', [3, 'Taylor Otwell', 'taylor@test.com']);
 }
开发者ID:elegantdevelopment,项目名称:laravel-messenger,代码行数:9,代码来源:TestCase.php

示例5: test_custom_meta_model

 public function test_custom_meta_model()
 {
     // This test is ridiculously complicated. There has to be an easier way!
     // If tests fail or error, you may have to clear out test.sqlite before running again
     // The `CustomModelParent` model uses a custom model to handle it's meta
     // The `CustomModelChild` handles meta for `CustomModelParent`
     // The `CustomModelChild` uses `custom_model_meta` as its table
     // First, create the `custom_model_parents` table and insert a record
     Capsule::schema()->create('custom_model_parents', function ($table) {
         $table->increments('id');
         $table->string('dummy', 255);
     });
     Capsule::insert('insert into custom_model_parents (dummy) values (?)', ['data']);
     // Second, create the `custom_model_meta` table
     Capsule::schema()->create('custom_model_meta', function ($table) {
         $table->increments('id');
         $table->integer('metable_id')->unsigned();
         $table->string('metable_type', 255);
         $table->string('key', 128);
         $table->text('value');
         $table->index('metable_id');
         $table->index('key');
     });
     // Start up the parent
     $model = CustomModelParent::find(1);
     // Now test that the CustomModelParent is working
     $this->assertEquals('this is a CustomModelParent method', $model->modelMethod(), 'failed to use custom method for Parent');
     // Test that data is being saved to the correct table
     $model->addMeta('testTable', 'value');
     $results = Capsule::select('select * from custom_model_meta');
     $this->assertEquals(['id' => 1, 'metable_id' => '1', 'metable_type' => 'Phoenix\\EloquentMeta\\Test\\Stubs\\CustomModelParent', 'key' => 'testTable', 'value' => 'value'], $results[0], "failed to get save meta to correct table");
     // Last, clean up our tables
     Capsule::schema()->drop('custom_model_meta');
     Capsule::schema()->drop('custom_model_parents');
 }
开发者ID:RonnyLV,项目名称:eloquent-meta,代码行数:35,代码来源:EloquentMetaTest.php


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