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


PHP DB::insert方法代码示例

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


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

示例1: record

 public function record()
 {
     if (\Request::hasFile('image') && \Request::file('image')->isValid() && \Auth::user()->suspend == false) {
         $file = \Request::file('image');
         $input = \Request::all();
         $date = new \DateTime();
         if (isset($input['anon'])) {
             $name = 'anon';
         } else {
             $name = \Auth::user()->name;
         }
         $validator = \Validator::make(array('image' => $file, 'category' => $input['category'], 'title' => $input['title'], 'caption' => $input['caption']), array('image' => 'required|max:1200|mimes:jpeg,jpg,gif', 'category' => 'required', 'title' => 'required|max:120', 'caption' => 'required|max:360'));
         if ($validator->fails()) {
             return redirect('/publish')->withErrors($validator);
         } else {
             $unique = str_random(10);
             $fileName = $unique;
             $destinationPath = 'database/pictures/stream_' . $input['category'] . '/';
             \Request::file('image')->move($destinationPath, $fileName);
             \DB::insert('insert into public.moderation (p_cat, p_ouser, p_title, p_caption, p_imgurl, p_status, p_reported, p_rating, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [$input['category'], $name, $input['title'], $input['caption'], $unique, 'available', 0, 0, $date, $date]);
             $messages = 'Your content has been succesfully submitted. Going on moderation process.';
             return redirect('/system/notification')->with('messages', $messages);
         }
     } else {
         $messages = 'Your content data is invalid. The process is aborted.';
         return redirect('/system/notification')->with('messages', $messages);
     }
 }
开发者ID:chandrairawan,项目名称:nosproject,代码行数:28,代码来源:PublicationController.php

示例2: SubmitScoreFinal

 public function SubmitScoreFinal(Requests\ScoreEntryFinalRequest $request)
 {
     $input = $request->all();
     \DB::$user = 'euro2016';
     \DB::$password = 'hllau860509';
     \DB::$dbName = 'Euro2016';
     $row = \DB::queryFirstRow("select * from Scores where MatchID = %i and UserID = %i", $request->matchid, Auth::user()->id);
     $count = \DB::count();
     //Log::info($count.' '.$request->matchid);
     \DB::startTransaction();
     if ($count == 0) {
         \DB::insert('Scores', array('MatchID' => $request->matchid, 'UserID' => Auth::user()->id, 'CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore));
     } else {
         \DB::update('Scores', array('CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore), "ID=%i", $row['ID']);
     }
     $affectedcount = \DB::affectedRows();
     \DB::update('Matches', array('CountryHomeID' => $request->CountryHomeID, 'CountryAwayID' => $request->CountryAwayID), "MatchID=%i", $request->matchid);
     \DB::commit();
     \DB::disconnect();
     // retrieve country names and flag
     $countrynamehome = \DB::queryFirstRow("select CountryName, Flag from Countries where CountryID = %i", $request->CountryHomeID);
     $countrynameaway = \DB::queryFirstRow("select CountryName, Flag from Countries where CountryID = %i", $request->CountryAwayID);
     $input['CountryHomeID'] = $countrynamehome['CountryName'];
     $input['CountryAwayID'] = $countrynameaway['CountryName'];
     $input['CountryHomeImage'] = $countrynamehome['Flag'];
     $input['CountryAwayImage'] = $countrynameaway['Flag'];
     //$input['CountryHID'] = $request->CountryHomeID;
     //$input['CountryAID'] = $request->CountryAwayID;
     return json_encode($input);
 }
开发者ID:hllau9,项目名称:Euro2016,代码行数:30,代码来源:AdminController.php

示例3: getSensor

 public function getSensor()
 {
     $id = $_SERVER['REMOTE_ADDR'];
     if (\DB::select('select 1 from module_vanguard where id = ?', [$id])) {
         if (\DB::select('select 1 from app_status where validity = true and sensor_register = true')) {
             $results = \DB::select('select * from module_vanguard where id = ?', [$id]);
             foreach ($results as $result) {
                 $alias = $result->alias;
                 $status = $result->status;
             }
             $timestamp = new \DateTime();
             if ($status == 'active') {
                 $must_report = true;
             }
             if ($status == 'passive') {
                 $must_report = false;
             }
             $is_reported = false;
             \DB::insert('insert into vanguard_log values (?, ?, ?, ?, ?)', [$id, $alias, $must_report, $is_reported, $timestamp]);
             //open to adjustment.
             exec("nodejs /var/www/topsus/nodejs/telegram_check.js");
             return 'OK';
         } else {
             return 'NOT OK - APPLICATION IS NOT LISTENING';
         }
     } else {
         return 'NOT OK - SENSOR IS INVALID';
     }
 }
开发者ID:taufiky1994,项目名称:BotAutomation,代码行数:29,代码来源:SensorController.php

示例4: access_2

 public function access_2()
 {
     $date = new \DateTime();
     $read = false;
     $value = \Request::input('value');
     $client = \Request::input('client');
     \DB::insert('insert into public.arduino (v_val, v_cli, v_read, created_at, updated_at) values (?, ?, ?, ?, ?)', [$value, $client, $read, $date, $date]);
     return 'This is X553M Server, your value is: ' . $value . ', From client: ' . $client;
 }
开发者ID:chandrairawan,项目名称:nosproject,代码行数:9,代码来源:ArduinoController.php

示例5: submitEditRequest

 public function submitEditRequest()
 {
     $request = \App::make('request');
     $request['store-id'] = '1';
     $request['key'] = 'sub-category';
     $request['value'] = 'swimming';
     $request['action'] = 'insert';
     \DB::insert("INSERT INTO `store_edit_requests` (`id`, `store_id`, `key`, `value`, `action`, `approved`, `created_at`, `updated_at`) VALUES (NULL, ?, ?, ?, ?, '', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)", [$request['store-id'], $request['key'], $request['value'], $request['action']]);
 }
开发者ID:bbig979,项目名称:shoppyst,代码行数:9,代码来源:StoreController.php

示例6: insert_robi_ticket

 public function insert_robi_ticket()
 {
     date_default_timezone_set('Asia/Dhaka');
     $escalation_time = date('Y/m/d h:i:s a', time());
     //secho $date;
     $client_id = $_SESSION['TICKET_USER_CLIENT_ID'];
     $client_type = $_SESSION['TICKET_USER_CLIENT_TYPE'];
     // $client_priority = Request::get('client_priority');
     // $link_type = Request::get('link_type');
     $problem_category = Request::get('problem_category');
     $problem_source = Request::get('problem_source');
     // $region = Request::get('region');
     $district = Request::get('district');
     // $reason = Request::get('reason');
     $event_time = Request::get('event_time');
     $link_name = Request::get('link_name');
     $client_impact = Request::get('client_impact');
     $client_site_count = Request::get('client_site_count');
     // $vendor_site_count = Request::get('vendor_site_count');
     // $vendor_impact = Request::get('vendor_impact');
     $remarks = Request::get('remarks');
     // $ticket_status = Request::get('ticket_status');
     // $responsible_vendor = Request::get('responsible_vendor');
     // $responsible_concern = Request::get('responsible_concern');
     // $responsible_field_team = Request::get('responsible_field_team');
     $query_insert_robi_ticket = "INSERT INTO ticket_table (client_id,client_type,client_priority,link_type,problem_category,problem_source,region,district,reason,event_time,escalation_time,link_name,client_impact,client_site_count,vendor_site_count, vendor_impact, remarks,ticket_status,responsible_vendor,responsible_concern,responsible_field_team,attachment_path) values ('" . $client_id . "','" . $client_type . "','NULL','NULL','" . $problem_category . "','" . $problem_source . "','NULL','" . $district . "','NULL','" . $event_time . "','" . $escalation_time . "','" . $link_name . "','" . $client_impact . "','" . $client_site_count . "','NULL','NULL','" . $remarks . "','open','NULL','NULL','NULL','NULL');";
     \DB::insert(\DB::raw($query_insert_robi_ticket));
     $result_list = \DB::select(\DB::raw("SELECT ticket_table_row_id FROM ticket_table ORDER BY ticket_table_row_id DESC limit 1"));
     foreach ($result_list as $result) {
         $ticket_table_row_id = $result->ticket_table_row_id;
     }
     if (Input::hasFile('attachment_path')) {
         // $path_test = '../Uploaded_Files/'.$ticket_table_row_id;
         // if(File::exists($path_test))
         // {
         //     File::delete($path_test);
         // }
         $dirPath = '../Uploaded_Files/';
         $files = Input::file('attachment_path');
         foreach ($files as $file) {
             // $filename = "test.txt";
             // $file->move($dirPath,$filename);
             $filename = $file->getClientOriginalName();
             $file->move($dirPath, $filename);
         }
     }
     $attachment_path = 'uploaded_files/' . $ticket_table_row_id;
     $ticket_update_querystring = "UPDATE ticket_table SET attachment_path='" . $attachment_path . "',ticket_id='" . $ticket_table_row_id . "' WHERE ticket_table_row_id='" . $ticket_table_row_id . "'";
     \DB::update(\DB::raw($ticket_update_querystring));
 }
开发者ID:amehraj,项目名称:ticket_system,代码行数:50,代码来源:ClientController.php

示例7: incrementVisitorCount

 public function incrementVisitorCount(Request $request)
 {
     $username = $request->username;
     $visitorUsername = $request->visitorusername;
     //return $username;
     try {
         if ($result = \DB::insert(\DB::raw("INSERT INTO  ProfileVisitor(prousername,visusername)\n              VALUES ('" . $username . "','" . $visitorUsername . "') "))) {
             return response()->json(['status' => 200], 200);
         } else {
             return response()->json(['status' => 505], 505);
         }
     } catch (Illuminate\Database\QueryException $e) {
     }
 }
开发者ID:rajikaimal,项目名称:Coupley,代码行数:14,代码来源:VisitorCountController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param CreateGroupRequest $request
  * @return Response
  */
 public function store(CreateGroupRequest $request)
 {
     $input = $request->all();
     $group = new Group();
     $group->name = $input['name'];
     $group->founderId = Auth::id();
     \DB::insert('INSERT INTO conversations VALUE ()');
     $conversationId = \DB::select('SELECT id FROM conversations ORDER BY id DESC LIMIT 1')[0]->id;
     $group->conversationId = $conversationId;
     $group->private = $request->type == "private" ? true : false;
     storeGroup($group);
     $mygroup = loadGroup($group->name)[0];
     addMemberToGroup($mygroup->founderId, $mygroup->id);
     return redirect('groups/' . $mygroup->id);
 }
开发者ID:arminnh,项目名称:website-learn-to-program,代码行数:21,代码来源:GroupsController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response|null
  */
 public function store(Request $request)
 {
     /**
      * @var $user \App\User
      */
     $user = \Auth::user();
     if (!$user) {
         return null;
     }
     $product_id = $request->get('product_id');
     $product_model = \App\Models\Product::findOrFail($product_id);
     $sql = 'INSERT IGNORE INTO ' . \App\Models\OrderedProduct::TABLE . ' (created_at, user_id, product_id, catalog_id, is_deferred) ' . 'VALUES (now(), ?, ?, ?, 1)';
     \DB::insert($sql, [$user->id, $product_id, $product_model->catalog_id]);
     return ['calls' => [['call' => 'updateHtmlContext', 'params' => ['#product-mini-item-' . $product_id, view('catalog.product_mini_item', ['product' => $product_model])->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-mini-box', view('basket.mini_box')->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-orders-container', view('basket.orders_items')->render()]]]];
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:21,代码来源:DeferredController.php

示例10: SubmitScore

 public function SubmitScore(Requests\ScoreEntryRequest $request)
 {
     $input = $request->all();
     \DB::$user = 'euro2016';
     \DB::$password = 'hllau860509';
     \DB::$dbName = 'Euro2016';
     $row = \DB::queryFirstRow("select * from Scores where MatchID = %i and UserID = %i", $request->matchid, Auth::user()->id);
     $count = \DB::count();
     if ($count == 0) {
         \DB::insert('Scores', array('MatchID' => $request->matchid, 'UserID' => Auth::user()->id, 'CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore));
     } else {
         \DB::update('Scores', array('CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore), "ID=%i", $row['ID']);
     }
     \DB::disconnect();
     return json_encode($input);
 }
开发者ID:hllau9,项目名称:Euro2016,代码行数:16,代码来源:GameController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response|null
  */
 public function store(Request $request)
 {
     /**
      * @var $user \App\User
      */
     $user = \Auth::user();
     if (!$user) {
         return null;
     }
     $product_id = $request->get('product_id');
     $product_model = \App\Models\Product::findOrFail($product_id);
     $sql = 'INSERT INTO ' . \App\Models\OrderedProduct::TABLE . ' (created_at, user_id, product_id, catalog_id, price, quantity) ' . 'VALUES (now(), ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE quantity = quantity + ?, updated_at = now()';
     $public_price = $product_model->getPublicPrice();
     $quantity = $request->get('quantity');
     \DB::insert($sql, [$user->id, $product_id, $product_model->catalog_id, $public_price, $quantity, $quantity]);
     return ['calls' => [['call' => 'updateHtmlContext', 'params' => ['#product-mini-item-' . $product_id, view('catalog.product_mini_item', ['product' => $product_model])->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-mini-box', view('basket.mini_box')->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-orders-container', view('basket.orders_items')->render()]]]];
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:23,代码来源:OrderController.php

示例12: Addcontactus

 public function Addcontactus()
 {
     //getting values of php form text boxes
     $name = $this->request->input('name');
     $email = $this->request->input('email');
     $phone = $this->request->input('phone');
     $services = $this->request->input('service');
     $subject = $this->request->input('subject');
     $message = $this->request->input('message');
     //return $this->request;
     try {
         $eventCatlist = \DB::select('select * from event_types');
         \DB::insert('insert into contactus (name, email, phone,service,subject,message) values (?, ?, ?, ?,?,?)', [$name, $email, $phone, $services, $subject, $message]);
     } catch (\Illuminate\Database\QueryException $e) {
         return view('website.contact')->with('message', 'Error occured while inserting data to the database')->with('type', 'error')->with('title', 'Error')->with('eventCatlist', $eventCatlist);
     }
     return view('website.contact')->with('message', 'Message Sent Successfully!')->with('type', 'success')->with('title', 'Message Sent Successfully!')->with('eventCatlist', $eventCatlist);
 }
开发者ID:gayankalhara,项目名称:planmyevent,代码行数:18,代码来源:CoreController.php

示例13: postCopy

 function postCopy(Request $request)
 {
     foreach (\DB::select("SHOW COLUMNS FROM tb_weight_pricing ") as $column) {
         if ($column->Field != 'id') {
             $columns[] = $column->Field;
         }
     }
     $toCopy = implode(",", $request->input('id'));
     $sql = "INSERT INTO tb_weight_pricing (" . implode(",", $columns) . ") ";
     $sql .= " SELECT " . implode(",", $columns) . " FROM tb_weight_pricing WHERE id IN (" . $toCopy . ")";
     \DB::insert($sql);
     return response()->json(array('status' => 'success', 'message' => \Lang::get('core.note_success')));
 }
开发者ID:sonoftheweb,项目名称:yallatracking_app,代码行数:13,代码来源:WeightbasedpricingController.php

示例14: postMultiupdate

 public function postMultiupdate(Request $request)
 {
     if ($this->access['is_add'] == 0) {
         return response()->json(array('status' => 'error', 'message' => \Lang::get('core.note_restric')));
         die;
     }
     // update status rows
     if (count($request->input('ids')) >= 1) {
         $ids = $request->input('ids');
         $data['status'] = 1;
         foreach ($ids as $value) {
             \DB::table('attendence_import_t')->where('import_id', $value)->update($data);
         }
         ///insertinto to another tanbel
         $sql = "INSERT INTO attendence_t  (attendence_id, employee_id, period_id, entry_date, entry_time, include_payroll, onduty) SELECT attendence_id, employee_id, period_id, date, time, includepayroll, onduty FROM attendance_importtoentry_v WHERE 1=1";
         \DB::insert($sql);
         return response()->json(array('status' => 'success', 'message' => 'Approved Successfully'));
     } else {
         return response()->json(array('status' => 'error', 'message' => \Lang::get('core.note_error')));
     }
 }
开发者ID:vtvmd2015,项目名称:symtec,代码行数:21,代码来源:AttendenceimportController.php

示例15: postAdd

 public function postAdd()
 {
     $input = \Request::all();
     if ($input['type'] == 'Vanguard') {
         if (\DB::select('select 1 from module_vanguard where id = ?', [$input['id']])) {
             $messages = 'Duplication, Sensor is Not Added.';
             return redirect('/add')->with('messages', $messages);
         } else {
             \DB::insert('insert into module_vanguard values (?, ?, ?)', [$input['id'], $input['alias'], 'passive']);
             $messages = 'A Sensor is Added.';
             return redirect('/add')->with('messages', $messages);
         }
     } else {
         $messages = 'A Sensor Type is Not Valid.';
         return redirect('/add')->with('messages', $messages);
     }
 }
开发者ID:taufiky1994,项目名称:BotAutomation,代码行数:17,代码来源:UserController.php


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