• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Facades\DB类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: storeJob

 /**
  * Store the job in the database.
  *
  * Returns the id of the job.
  *
  * @param string $job
  * @param mixed  $data
  * @param int    $delay
  *
  * @return int
  */
 public function storeJob($job, $data, $delay = 0)
 {
     $payload = $this->createPayload($job, $data);
     $database = Config::get('database');
     if ($database['default'] === 'odbc') {
         $row = DB::select(DB::raw("SELECT laq_async_queue_seq.NEXTVAL FROM DUAL"));
         $id = $row[0]->nextval;
         $job = new Job();
         $job->id = $id;
         $job->status = Job::STATUS_OPEN;
         $job->delay = $delay;
         $job->payload = $payload;
         $job->save();
     } else {
         if ($database['default'] === 'mysql') {
             $payload = $this->createPayload($job, $data);
             $job = new Job();
             $job->status = Job::STATUS_OPEN;
             $job->delay = $delay;
             $job->payload = $payload;
             $job->save();
             $id = $job->id;
         }
     }
     return $id;
 }
开发者ID:studentjason,项目名称:laravel-async-queue,代码行数:37,代码来源:AsyncQueue.php


示例2: run

 public function run()
 {
     DB::table('master_type_bank')->delete();
     $data = array(array('name' => 'TABUNGAN', 'info' => '', 'uuid' => uniqid(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime(), 'createby_id' => 1, 'lastupdateby_id' => 1), array('name' => 'GIRO', 'info' => '', 'uuid' => uniqid(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime(), 'createby_id' => 1, 'lastupdateby_id' => 1), array('name' => 'DEPOSITO', 'info' => '', 'uuid' => uniqid(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime(), 'createby_id' => 1, 'lastupdateby_id' => 1));
     DB::table('master_type_bank')->insert($data);
     $this->command->info('Done [' . __CLASS__ . ']');
 }
开发者ID:emayk,项目名称:ics,代码行数:7,代码来源:Bank_Type_Account.php


示例3: materiaMaestroEnpalme

 public function materiaMaestroEnpalme()
 {
     $maestroId = Materia::join('maestro_materia', 'materias.id', '=', 'maestro_materia.materia_id')->where('materia_id', '=', Input::get('materia_id'))->select('materia', 'materia_id', 'maestro_id')->first();
     $maestroMateria = DB::table('horarios')->join('materias', 'materias.id', '=', 'horarios.materia_id')->join('maestro_materia', 'maestro_materia.materia_id', '=', 'materias.id')->join('maestros', 'maestros.id', '=', 'maestro_materia.maestro_id')->where('hora_id', Input::get('hora_id'))->where('horarios.ciclo_id', Input::get('ciclo_id'))->where('dia_id', Input::get('dia_id'))->where('maestro_id', $maestroId->maestro_id)->get();
     //dd($maestroMateria);
     return $maestroMateria;
 }
开发者ID:elektroacustica,项目名称:horario-frontend,代码行数:7,代码来源:MateriaRepo.php


示例4: keywords

 public function keywords()
 {
     $limit = 25;
     $projections = array('id', 'value');
     $keywords = DB::collection('map_reduce_twitter_words')->orderBy('value', 'desc')->paginate($limit, $projections);
     return view('keywords')->with(['keywords' => $keywords]);
 }
开发者ID:khamkham,项目名称:Laravel-Twitter-MongoDB,代码行数:7,代码来源:MongoController.php


示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tags')->insert(['title' => "camiseta"]);
     DB::table('tags')->insert(['title' => "preta"]);
     DB::table('tags')->insert(['title' => "branca"]);
     DB::table('tags')->insert(['title' => "amarela"]);
 }
开发者ID:justem007,项目名称:rossina,代码行数:12,代码来源:TagTableSeeder.php


示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('roles')->truncate();
     //insert some dummy records
     Role::create(['name' => 'Admin', 'status' => 'active']);
     /*Role::create([
             'name' => 'Project Manager',
             'status' => 'active',
             ]);
     
             Role::create([
             'name' => 'Team Lead',
             'status' => 'active',
             ]);
     
             Role::create([
             'name' => 'Developer',
             'status' => 'active',
             ]);
     
             Role::create([
             'name' => 'Designer',
             'status' => 'active',
             ]);
     
             Role::create([
             'name' => 'Tester',
             'status' => 'active',
             ]);*/
     DB::table('roles_users')->insert(['user_id' => 1, 'role_id' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
 }
开发者ID:komalsavla10,项目名称:timesheet,代码行数:36,代码来源:RolesTableSeeder.php


示例7: getValuesByHour

 /**
  * Returns the sum of all values a metric has by the hour.
  *
  * @param int $hour
  *
  * @return int
  */
 public function getValuesByHour($hour)
 {
     $dateTimeZone = SettingFacade::get('app_timezone');
     $dateTime = (new Date())->setTimezone($dateTimeZone)->sub(new DateInterval('PT' . $hour . 'H'));
     $hourInterval = $dateTime->format('YmdH');
     if (Config::get('database.default') === 'mysql') {
         if (!isset($this->calc_type) || $this->calc_type == self::CALC_SUM) {
             $value = (int) $this->points()->whereRaw('DATE_FORMAT(created_at, "%Y%m%d%H") = ' . $hourInterval)->groupBy(DB::raw('HOUR(created_at)'))->sum('value');
         } elseif ($this->calc_type == self::CALC_AVG) {
             $value = (int) $this->points()->whereRaw('DATE_FORMAT(created_at, "%Y%m%d%H") = ' . $hourInterval)->groupBy(DB::raw('HOUR(created_at)'))->avg('value');
         }
     } else {
         // Default metrics calculations.
         if (!isset($this->calc_type) || $this->calc_type == self::CALC_SUM) {
             $queryType = 'sum(metric_points.value)';
         } elseif ($this->calc_type == self::CALC_AVG) {
             $queryType = 'avg(metric_points.value)';
         } else {
             $queryType = 'sum(metric_points.value)';
         }
         $query = DB::select("select {$queryType} as aggregate FROM metrics JOIN metric_points ON metric_points.metric_id = metrics.id WHERE metric_points.metric_id = {$this->id} AND to_char(metric_points.created_at, 'YYYYMMDDHH24') = :timestamp GROUP BY to_char(metric_points.created_at, 'H')", ['timestamp' => $hourInterval]);
         if (isset($query[0])) {
             $value = $query[0]->aggregate;
         } else {
             $value = 0;
         }
     }
     if ($value === 0 && $this->default_value != $value) {
         return $this->default_value;
     }
     return $value;
 }
开发者ID:nguyentamvinhlong,项目名称:Cachet,代码行数:39,代码来源:Metric.php


示例8: canStartForeignKeysCheckIfSupported

 /**
  * @test
  **/
 public function canStartForeignKeysCheckIfSupported()
 {
     $mock_exec = m::mock('StdClass')->shouldReceive('exec')->once()->with('SET FOREIGN_KEY_CHECKS=1;')->getMock();
     $mock_getPdo = m::mock('StdClass')->shouldReceive('getPdo')->once()->andReturn($mock_exec)->getMock();
     DB::shouldReceive('connection')->once()->andReturn($mock_getPdo);
     DbHelperStub::startForeignKeysCheck();
 }
开发者ID:yoganandgopalan,项目名称:InventoryCarShowroom,代码行数:10,代码来源:DbHelperTest.php


示例9: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $count = 0;
     $pdo = DB::connection()->getPdo();
     $query = "SELECT * FROM archivos_sat;";
     $stmt = $pdo->prepare($query);
     $stmt->execute();
     while ($row = $stmt->fetchObject()) {
         $count++;
         if ($count % 100 == 0) {
             $this->comment("arch sat: " . $count);
         }
         $archivo = ArchivoSat::find($row->id);
         $parser = new ParserCFID($archivo->file);
         $parser->parser();
         $archivo->fecha = $parser->getFecha();
         $archivo->save();
     }
     $count = 0;
     $pdo = DB::connection()->getPdo();
     $query = "SELECT * FROM archivos_empresa;";
     $stmt = $pdo->prepare($query);
     $stmt->execute();
     while ($row = $stmt->fetchObject()) {
         $count++;
         if ($count % 100 == 0) {
             $this->comment("arch emp: " . $count);
         }
         $archivo = ArchivoEmpresa::find($row->id);
         $parser = new ParserCFID($archivo->file);
         $parser->parser();
         $archivo->fecha = $parser->getFecha();
         $archivo->save();
     }
 }
开发者ID:diego1q2w,项目名称:validador,代码行数:40,代码来源:AssignFecha.php


示例10: purgeOldAvatars

 /**
  * Remove unused avatar files from disk.
  *
  * @return void
  */
 private function purgeOldAvatars()
 {
     // Build up a list of all avatar images
     $avatars = glob(public_path() . '/upload/*/*.*');
     // Remove the public_path() from the path so that they match values in the DB
     array_walk($avatars, function (&$avatar) {
         $avatar = str_replace(public_path(), '', $avatar);
     });
     $all_avatars = collect($avatars);
     // Get all avatars currently assigned
     $current_avatars = DB::table('users')->whereNotNull('avatar')->lists('avatar');
     // Compare the 2 collections get a list of avatars which are no longer assigned
     $orphan_avatars = $all_avatars->diff($current_avatars);
     $this->info('Found ' . $orphan_avatars->count() . ' orphaned avatars');
     // Now loop through the avatars and delete them from storage
     foreach ($orphan_avatars as $avatar) {
         $avatarPath = public_path() . $avatar;
         // Don't delete recently created files as they could be temp files from the uploader
         if (filemtime($avatarPath) > strtotime('-15 minutes')) {
             $this->info('Skipping ' . $avatar);
             continue;
         }
         if (!unlink($avatarPath)) {
             $this->error('Failed to delete ' . $avatar);
         } else {
             $this->info('Deleted ' . $avatar);
         }
     }
 }
开发者ID:piyushpk89,项目名称:deployer,代码行数:34,代码来源:ClearOrphanAvatars.php


示例11: unlink

 public function unlink(Module $module, Request $request, FileRepository $fileRepository, Imagy $imagy)
 {
     DB::table('media__imageables')->whereFileId($request->get('fileId'))->delete();
     $file = $fileRepository->find($request->get('fileId'));
     $imagy->deleteAllFor($file);
     $fileRepository->destroy($file);
 }
开发者ID:okao,项目名称:Website,代码行数:7,代码来源:ModuleController.php


示例12: up

 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::table('deployments', function (Blueprint $table) {
         $table->boolean('is_webhook')->default(false);
     });
     DB::table('deployments')->whereRaw('user_id IS NULL')->update(['is_webhook' => true]);
 }
开发者ID:rebelinblue,项目名称:deployer,代码行数:10,代码来源:2015_10_06_083529_add_is_webhook.php


示例13: run

 public function run()
 {
     DB::table('partners')->delete();
     Partner::create(['applicant_id' => 1, 'partner' => 'Pepper Potts', 'title' => 'CFO', 'location' => 'Monroe, LA', 'email' => '[email protected]', 'phone' => '5125551020']);
     Partner::create(['applicant_id' => 1, 'partner' => 'James Rhodes', 'title' => 'Colonel', 'location' => 'Norfolk, VA', 'email' => '[email protected]', 'phone' => '5125559999']);
     Partner::create(['applicant_id' => 4, 'partner' => 'Sam Wilson', 'title' => 'Falcon', 'location' => 'Washington, D.C.', 'email' => '[email protected]', 'phone' => '5125995599']);
 }
开发者ID:wyrover,项目名称:lenda-api,代码行数:7,代码来源:PartnersTableSeeder.php


示例14: postSendsms

 public function postSendsms(Request $request)
 {
     $mobile = Input::get('mobile');
     if (!preg_match("/1[3458]{1}\\d{9}\$/", $mobile)) {
         // if(!preg_match("/^13\d{9}$|^14\d{9}$|^15\d{9}$|^17\d{9}$|^18\d{9}$/",$mobile)){
         //手机号码格式不对
         return parent::returnJson(1, "手机号码格式不对" . $mobile);
     }
     $data = DB::select("select * from members where lifestatus=1 and mobile =" . $mobile);
     if (sizeof($data) > 0) {
         return parent::returnJson(1, "手机号已注册");
     }
     $checkCode = parent::get_code(6, 1);
     Session::put("m" . $mobile, $checkCode);
     $checkCode = Session::get("m" . $mobile);
     Log::error("sendsms:session:" . $checkCode);
     $msg = "尊敬的用户:" . $checkCode . "是您本次的短信验证码,5分钟内有效.";
     // Input::get('msg');
     $curl = new cURL();
     $serverUrl = "http://cf.lmobile.cn/submitdata/Service.asmx/g_Submit";
     $response = $curl->get($serverUrl . "?sname=dlrmcf58&spwd=ZRB2aP8K&scorpid=&sprdid=1012818&sdst=" . $mobile . "&smsg=" . rawurlencode($msg . "【投贷宝】"));
     $xml = simplexml_load_string($response);
     echo json_encode($xml);
     //$xml->State;
     //  <CSubmitState xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
     //   <State>0</State>
     //   <MsgID>1512191953407413801</MsgID>
     //   <MsgState>提交成功</MsgState>
     //   <Reserve>0</Reserve>
     // </CSubmitState>
     // <State>1023</State>
     //  <MsgID>0</MsgID>
     //  <MsgState>无效计费条数,号码不规则,过滤[1:186019249011,]</MsgState>
     //  <Reserve>0</Reserve>
 }
开发者ID:jacke121,项目名称:tdbasset,代码行数:35,代码来源:AreaController.php


示例15: run

 public function run()
 {
     for ($i = 0; $i < 100; $i++) {
         DB::table('posts_has_tags')->insert(['post_id' => $i + 1, 'tag_id' => rand(1, 2)]);
         DB::table('posts_has_tags')->insert(['post_id' => $i + 1, 'tag_id' => rand(3, 4)]);
     }
 }
开发者ID:thepopix,项目名称:backend,代码行数:7,代码来源:PostHasTagTableSeeder.php


示例16: postLogin

 public function postLogin(LoginRequest $request)
 {
     if (!Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')], true)) {
         session()->flash('errorMessages', ['You have entered an invalid email address or password.', 'Please try again.']);
         return back()->withInput();
     }
     $user = Auth::user();
     // if the user has a plant, set welcome message
     if (count($user->plants)) {
         $plant = $user->plants()->where('isHarvested', '=', false)->orderBy(DB::raw('RAND()'))->first();
         if ($plant) {
             // set welcome message to need water or need fertilizer if the plant needs it
             $lastTimeWatered = $plant->getLastTimeWatered();
             $lastTimeFertilized = $plant->getLastTimeFertilized();
             $random = round(rand(1, 2));
             if (!$lastTimeWatered && $plant->created_at->addDay() < Carbon::now()) {
                 $status = $plant->plantCharacter['need_water_phrase_' . $random];
             } elseif (!$lastTimeFertilized && $plant->created_at->addDay() < Carbon::now()) {
                 $status = $plant->plantCharacter['need_fertilizer_phrase_' . $random];
             } elseif ($lastTimeWatered && Carbon::createFromFormat('Y-m-d H:i:s', $lastTimeWatered->pivot->date)->addDay() < Carbon::now()) {
                 $status = $plant->plantCharacter['need_water_phrase_' . $random];
             } elseif ($lastTimeFertilized && Carbon::createFromFormat('Y-m-d H:i:s', $lastTimeFertilized->pivot->date)->addDay() < Carbon::now()) {
                 $status = $plant->plantCharacter['need_fertilizer_phrase_' . $random];
             } else {
                 $status = $plant->plantCharacter['welcome_phrase_' . $random];
             }
             session()->flash('message', $plant->plantCharacter->name . ': ' . $status);
         }
     }
     return redirect()->route('dashboard');
 }
开发者ID:DriesVS,项目名称:gardening-for-lazy-people,代码行数:31,代码来源:AuthController.php


示例17: run

 public function run()
 {
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     }
     if (env('DB_DRIVER') == 'mysql') {
         DB::table(config('access.roles_table'))->truncate();
     } else {
         //For PostgreSQL or anything else
         DB::statement("TRUNCATE TABLE " . config('access.roles_table') . " CASCADE");
     }
     //Create admin role, id of 1
     $role_model = config('access.role');
     $admin = new $role_model();
     $admin->name = 'Administrator';
     $admin->all = true;
     $admin->sort = 1;
     $admin->created_at = Carbon::now();
     $admin->updated_at = Carbon::now();
     $admin->save();
     //id = 2
     $role_model = config('access.role');
     $user = new $role_model();
     $user->name = 'User';
     $user->sort = 2;
     $user->created_at = Carbon::now();
     $user->updated_at = Carbon::now();
     $user->save();
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     }
 }
开发者ID:Interlista,项目名称:HackADev,代码行数:32,代码来源:RoleTableSeeder.php


示例18: getMmPoint

 public function getMmPoint(Request $request)
 {
     $key = request('key');
     $mmpointM = DB::connection(DBUtils::getDBName())->table('mmpoint_table')->where('A', $key)->first();
     // Log::info("lenth ".sizeof($mmtrendM));
     return response()->json(['mmpointM' => json_encode($mmpointM)]);
 }
开发者ID:imakedev,项目名称:ais5_2,代码行数:7,代码来源:PointDesignAjax.php


示例19: total

 public function total()
 {
     $result = Trainer::select(DB::raw('sum(full_time_male) as male,
                                         sum(full_time_female) as female,
                                         sum(full_time_male) + sum(full_time_female) as total'))->where('report_date_id', $this->report_date_id)->where('institution_id', $this->institution_id)->get();
     return $result;
 }
开发者ID:rdg577,项目名称:laravel-mis,代码行数:7,代码来源:TVIIndicator1TrainerRatio.php


示例20: clear

 public function clear(Request $request)
 {
     $post = $request->all();
     $comment = $post['comment'];
     $value = $post['amount'];
     $student = $post['regNo'];
     $clearedAt = $post['signedAt'];
     $clearedBy = $post['signedBy'];
     $comment = preg_replace('/[^A-Za-z0-9 _]/', '', $comment);
     $value = preg_replace('/[^0-9]/', '', $value);
     DB::beginTransaction();
     $submit = DB::update("UPDATE charge\n            INNER JOIN comments ON charge.students_studentNo = comments.students_studentNo\n            INNER JOIN cleared_at ON charge.students_studentNo = cleared_at.students_studentNo\n            INNER JOIN cleared_by ON charge.students_studentNo = cleared_by.students_studentNo\n            SET\n            charge.cafeteria_value = '{$value}',\n            charge.queueFlag = charge.queueFlag + 1,\n            comments.cafeteria = '{$comment}',\n            cleared_at.cafeteria_cleared_at = '{$clearedAt}',\n            cleared_by.cafeteria_cleared_by = '{$clearedBy}'\n\n            WHERE charge.students_studentNo = '{$student}'\n            AND comments.students_studentNo = '{$student}'\n            AND cleared_at.students_studentNo = '{$student}'\n            AND cleared_by.students_studentNo='{$student}' ");
     if ($submit) {
         DB::commit();
     } else {
         DB::rollBack();
     }
     // $admin = DB::table('departments')
     //         ->join('administrators','departments.administrator','=','administrators.admin_id')
     //         ->select('administrators.email')->where('departments.department_name','=','Library')
     //         ->pluck('email');
     //Send Mail
     // Mail::send('mails.clear', ['student' => $student ], function($message) use($admin){
     //     $message->to($admin)->from('[email protected]', 'Strathmore University')->subject('Clearance');
     // });
     return redirect('/cafeteria');
 }
开发者ID:bryan-mwas,项目名称:Clearance101,代码行数:27,代码来源:CafeteriaController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Facades\Event类代码示例发布时间:2022-05-23
下一篇:
PHP Facades\Config类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap