當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Facades\DB類代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\DB的典型用法代碼示例。如果您正苦於以下問題:PHP DB類的具體用法?PHP DB怎麽用?PHP DB使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DB類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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' => 'ppotts@marvel.com', 'phone' => '5125551020']);
     Partner::create(['applicant_id' => 1, 'partner' => 'James Rhodes', 'title' => 'Colonel', 'location' => 'Norfolk, VA', 'email' => 'warmachine@marvel.com', 'phone' => '5125559999']);
     Partner::create(['applicant_id' => 4, 'partner' => 'Sam Wilson', 'title' => 'Falcon', 'location' => 'Washington, D.C.', 'email' => 'falcon@marvel.com', '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


注:本文中的Illuminate\Support\Facades\DB類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。