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


PHP DB::getPdo方法代码示例

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


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

示例1: store

 public function store(Request $request)
 {
     $input = $request->all();
     $unit = Units::findOrFail($input['unit_id']);
     $item = Items::findOrFail($input['item_id']);
     if (array_key_exists('default', $input)) {
         DB::table('item_units')->where(['default' => 1, 'item_id' => $input['item_id']])->update(['default' => 0]);
         $input['default'] = 1;
         DB::statement('INSERT INTO item_units (`item_id`, `unit_id`, `factor`, `default`, `updated_at`, `created_at`) VALUES (' . $input['item_id'] . ', ' . $input['unit_id'] . ', ' . $input['factor'] . ', ' . $input['default'] . ', NOW(), NOW())');
         Helper::add(DB::getPdo()->lastInsertId(), 'added unit ' . $unit->title . ' for item ' . $item->title . ' (ID ' . $input['item_id'] . ')');
         Helper::add(DB::getPdo()->lastInsertId(), 'changed item ' . $item->title . ' (ID ' . $input['item_id'] . ') default unit to ' . $unit->title);
         ItemUnits::where(['item_id' => $input['item_id']])->update(['factor' => DB::raw('factor/' . $input['factor'])]);
         StockItem::where(['item_id' => $input['item_id']])->update(['stock' => DB::raw('stock/' . $input['factor'])]);
         RecipeItems::where(['item_id' => $input['item_id']])->update(['value' => DB::raw('value/' . $input['factor'])]);
         Menu::where(['item_id' => $input['item_id']])->update(['value' => DB::raw('value/' . $input['factor'])]);
         ItemPurchases::where(['item_id' => $input['item_id']])->update(['value' => DB::raw('value/' . $input['factor'])]);
         StockCheck::where(['item_id' => $input['item_id']])->update(['before' => DB::raw('`before` / ' . $input['factor']), 'after' => DB::raw('`after` / ' . $input['factor'])]);
     } else {
         $input['default'] = 0;
         DB::statement('INSERT INTO item_units (`item_id`, `unit_id`, `factor`, `default`, `updated_at`, `created_at`) VALUES (' . $input['item_id'] . ', ' . $input['unit_id'] . ', ' . $input['factor'] . ', ' . $input['default'] . ', NOW(), NOW())');
         Helper::add(DB::getPdo()->lastInsertId(), 'added unit ' . $unit->title . ' for item ' . $item->title . ' (ID ' . $input['item_id'] . ')');
     }
     //Units::create($input);
     Session::flash('flash_message', $this->title . ' successfully added!');
     return Redirect::action('ItemsController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:26,代码来源:ItemUnitsController.php

示例2: up

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::transaction(function () {
            $newDate = '2016-01-01 00:00:00';
            if (Schema::hasTable('comments')) {
                if (!Schema::hasColumn('comments', 'companionship_id')) {
                    Schema::table('comments', function (Blueprint $table) {
                        $table->integer('companionship_id')->unsigned()->after('member_id');
                    });
                }
                DB::update('UPDATE comments SET created_at = ?, updated_at = ? WHERE created_at = ?', [$newDate, $newDate, '0000-00-00 00:00:00']);
                DB::update('UPDATE ward_companions SET created_at = ?, updated_at = ? WHERE created_at = ?', [$newDate, $newDate, '0000-00-00 00:00:00']);
                $companionships = DB::select('
					SELECT c.id AS commentId, c.member_id AS commentMemberId, c.companion_id AS commentCompanion, wc.*, c.family_id
					FROM comments AS c
					LEFT JOIN ward_companions AS wc
					ON (ht_one_id = c.member_id OR ht_one_id = c.companion_id)
					AND (ht_two_id = c.member_id OR ht_two_id = c.companion_id)
					ORDER BY commentId ASC');
                $date = '2000-01-01 00:00:00';
                foreach ($companionships as $companionship) {
                    if (empty($companionship->id)) {
                        $member = DB::table('members')->find($companionship->commentMemberId);
                        DB::table('ward_companions')->insert(['ht_one_id' => $companionship->commentMemberId, 'ht_two_id' => $companionship->commentCompanion, 'ward_id' => $member->ward_id, 'district_id' => 0, 'quorum_id' => $member->quorum_id, 'family_id' => $companionship->family_id, 'created_at' => $date, 'updated_at' => $date, 'deleted_at' => $date]);
                        $companionship->id = DB::getPdo()->lastInsertId();
                    }
                    DB::update('UPDATE comments SET companionship_id = ? WHERE id = ?', [$companionship->id, $companionship->commentId]);
                }
                Schema::table('comments', function (Blueprint $table) {
                    $table->dropColumn(['ward_id', 'companion_id']);
                });
            }
        });
    }
开发者ID:joshdavis11,项目名称:hometeachme,代码行数:39,代码来源:2016_02_12_033548_remove_ward_id_from_comments.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // Creando modulo de contabilidad
     DB::table('modules')->insert([['module_name' => 'Contabilidad']]);
     $idContabilidad = DB::getPdo()->lastInsertId();
     DB::table('modules_permissions')->insert([['module_id' => $idContabilidad, 'display_name' => 'Ver ventas', 'permission' => 'ventas.view'], ['module_id' => $idContabilidad, 'display_name' => 'Ver pendientes', 'permission' => 'pendientes.view'], ['module_id' => $idContabilidad, 'display_name' => 'Ver depositos', 'permission' => 'depositos.view'], ['module_id' => $idContabilidad, 'display_name' => 'Ver cancelaciones', 'permission' => 'cancelaciones.view'], ['module_id' => $idContabilidad, 'display_name' => 'Ver polizas', 'permission' => 'polizas.view'], ['module_id' => $idContabilidad, 'display_name' => 'Ver antigüedad de saldos', 'permission' => 'antiguedad.view'], ['module_id' => $idContabilidad, 'display_name' => 'Ver auxiliar de movimientos', 'permission' => 'auxmovimientos.view'], ['module_id' => $idContabilidad, 'display_name' => 'Ver estado de cuenta', 'permission' => 'estadocuenta.view']]);
 }
开发者ID:gitfreengers,项目名称:larus,代码行数:13,代码来源:ContabilidadDatabaseSeeder.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('modules')->insert([['module_name' => 'Tareas']]);
     $module_id = DB::getPdo()->lastInsertId();
     DB::table('modules_permissions')->insert([['module_id' => $module_id, 'display_name' => 'Ver tareas', 'permission' => 'task.view'], ['module_id' => $module_id, 'display_name' => 'Crear tarea', 'permission' => 'task.create'], ['module_id' => $module_id, 'display_name' => 'Actualizar tarea', 'permission' => 'task.update'], ['module_id' => $module_id, 'display_name' => 'Eliminar tarea', 'permission' => 'task.delete']]);
     // $this->call("OthersTableSeeder");
 }
开发者ID:gitfreengers,项目名称:larus,代码行数:13,代码来源:TasksDatabaseSeeder.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['reason' => 'required|max:500']);
     $input = $request->all();
     WasteReasons::create($input);
     Helper::add(DB::getPdo()->lastInsertId(), 'added new waste reason (ID ' . DB::getPdo()->lastInsertId() . ')');
     Session::flash('flash_message', $this->title . ' successfully added!');
     return Redirect::action('WasteReasonsController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:14,代码来源:WasteReasonsController.php

示例6: create

 static function create($entry)
 {
     DB::insert('INSERT INTO Entries(name, real_name, email, id_game, campus, time, id_team, password, is_approved) VALUES (:name, :real_name, :email, :id_game, :campus, :time, :id_team, :password, :is_approved)', $entry);
     $id = DB::getPdo()->lastInsertId();
     //		if (!empty($entry->extra_fields)) {
     //			this.insertFieldEntries($id, $entry->extra_entries);
     //		}
     return $id;
 }
开发者ID:grit45,项目名称:EEISTI-Tournaments,代码行数:9,代码来源:Entry.php

示例7: store

 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|unique:unit_groups|max:100']);
     $input = $request->all();
     UnitGroups::create($input);
     Helper::add(DB::getPdo()->lastInsertId(), 'added new unit group ' . $input['title'] . ' (ID ' . DB::getPdo()->lastInsertId() . ')');
     Session::flash('flash_message', $this->title . ' successfully added!');
     return Redirect::action('UnitGroupsController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:9,代码来源:UnitGroupsController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['vat' => 'max:20']);
     $input = $request->all();
     Suppliers::create($input);
     Helper::add(DB::getPdo()->lastInsertId(), 'added new suppliers ' . $input['title'] . ' (ID ' . DB::getPdo()->lastInsertId() . ')');
     Session::flash('flash_message', $this->title . ' successfully added!');
     return Redirect::action('SuppliersController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:14,代码来源:SuppliersController.php

示例9: create

 static function create($game)
 {
     DB::insert('INSERT INTO Games(name, num_players, nickname_field, multicampus) VALUES (:name, :num_players, :nickname_field, :multicampus)', $game);
     $id = DB::getPdo()->lastInsertId();
     //		if (!empty($game->extra_fields)) {
     //			this.insertFields($id, $game->extra_fields);
     //		}
     return $id;
 }
开发者ID:grit45,项目名称:EEISTI-Tournaments,代码行数:9,代码来源:Game.php

示例10: update

 public function update($id, Request $request)
 {
     $ItemCategories = ItemCategories::findOrFail($id);
     $this->validate($request, ['title' => 'required|max:100']);
     $input = $request->all();
     DB::statement('UPDATE item_categories SET parent_id = ' . ($input['parent_id'] ? $input['parent_id'] : 'NULL') . ', title = "' . $input['title'] . '", updated_at = NOW() WHERE id = ' . $ItemCategories->id);
     Helper::add(DB::getPdo()->lastInsertId(), 'updated items category ' . $input['title']);
     Session::flash('flash_message', $this->title . ' successfully updated!');
     return Redirect::action('ItemCategoriesController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:10,代码来源:ItemCategoriesController.php

示例11: insert

 public function insert($input = array())
 {
     foreach ($input as $key => $value) {
         $fieldDB[] = $key;
         $valueData[] = $value;
     }
     $infields = implode(",", $fieldDB);
     $inValues = implode("','", $valueData);
     $insert = app('db')->insert("INSERT INTO {$this->table_name}({$infields}) VALUE ('" . $inValues . "')");
     return DB::getPdo()->lastInsertId();
 }
开发者ID:phamxuancan,项目名称:truck,代码行数:11,代码来源:ModelBase.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|unique:users|max:100']);
     $input = $request->all();
     $active = array_key_exists('active', $input) ? 1 : 0;
     $input['active'] = $active;
     $input['password'] = Hash::make($input['password']);
     User::create($input);
     Helper::add(DB::getPdo()->lastInsertId(), 'added user ' . $input['name'] . ' (ID ' . DB::getPdo()->lastInsertId() . ')');
     Session::flash('flash_message', $this->title . ' successfully added!');
     return Redirect::action('UsersController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:17,代码来源:UsersController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $recipe = Recipes::findOrFail($input['recipe_id']);
     if ($input['type'] == 'recipe') {
         $item = Recipes::findOrFail($input['sub_recipe']);
     } else {
         $item = Items::findOrFail($input['item_id']);
     }
     RecipeItems::create($input);
     Helper::add(DB::getPdo()->lastInsertId(), 'added ' . $input['type'] . ' ' . $item->title . ' (ID ' . $recipe->id . ') to recipe ' . $recipe->title . ' (ID ' . $recipe->id . ')');
     Session::flash('flash_message', $this->title . ' successfully added!');
     return Redirect::action('RecipeItemsController@index', $request->get('recipe_id'));
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:19,代码来源:RecipeItemsController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $periods = StockPeriods::orderBy('date_from', 'DESC')->get();
     $input['number'] = 1;
     if (count($periods) > 0) {
         $input['number'] = $periods->first()->number + 1;
     }
     if (array_key_exists('last_period', $input)) {
         $last_period = StockPeriods::findOrFail($input['last_period']);
         $last_period->update(['date_to' => $input['date_from']]);
         $last_period->save();
     }
     StockPeriods::create($input);
     Helper::add(DB::getPdo()->lastInsertId(), '');
     return Redirect::action('StockPeriodsController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:22,代码来源:StockPeriodsController.php

示例15: store

 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|unique:units|max:100']);
     $input = $request->all();
     $group = UnitGroups::findOrFail($input['group_id']);
     if (array_key_exists('default', $input)) {
         DB::table('units')->where(['default' => 1, 'group_id' => $input['group_id']])->update(['default' => 0]);
         $input['default'] = 1;
         Units::create($input);
         Helper::add(DB::getPdo()->lastInsertId(), 'added new unit ' . $input['title'] . ' (ID ' . DB::getPdo()->lastInsertId() . ')');
         Helper::add(DB::getPdo()->lastInsertId(), 'changed default unit to ' . $input['title'] . ' (ID ' . DB::getPdo()->lastInsertId() . ') in group ' . $group->title . ' (ID ' . $group->id . ')');
         Units::where(['group_id' => $input['group_id']])->update(['factor' => DB::raw('factor/' . $input['factor'])]);
     } else {
         Units::create($input);
         Helper::add(DB::getPdo()->lastInsertId(), 'added new unit ' . $input['title'] . ' (ID ' . DB::getPdo()->lastInsertId() . ')');
     }
     Session::flash('flash_message', $this->title . ' successfully added!');
     return Redirect::action('UnitsController@index');
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:19,代码来源:UnitsController.php


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