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


PHP DB::getDriverName方法代码示例

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


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

示例1: release

 public function release($id)
 {
     $locks_remaining = $this->popLock($id);
     if ($locks_remaining > 0) {
         return true;
     }
     $driver_name = DB::getDriverName();
     if ($driver_name == 'mysql') {
         $released = $this->release_Mysql($id);
     } else {
         $released = $this->release_Memory($id);
     }
     return $released;
 }
开发者ID:tokenly,项目名称:laravel-record-lock,代码行数:14,代码来源:RecordLock.php

示例2: filtering

 /**
  * Datatable filtering
  *
  * @return null
  */
 private function filtering()
 {
     $columns = $this->clean_columns($this->columns, false);
     if (Input::get('sSearch', '') != '') {
         $copy_this = $this;
         $copy_this->columns = $columns;
         $this->query->where(function ($query) use($copy_this) {
             $db_prefix = $copy_this->database_prefix();
             for ($i = 0, $c = count($copy_this->columns); $i < $c; $i++) {
                 if (Input::get('bSearchable_' . $i) == "true") {
                     $column = $copy_this->columns[$i];
                     if (stripos($column, ' AS ') !== false) {
                         $column = substr($column, stripos($column, ' AS ') + 4);
                     }
                     $keyword = '%' . Input::get('sSearch') . '%';
                     if (Config::get('datatables.search.use_wildcards', false)) {
                         $keyword = $copy_this->wildcard_like_string(Input::get('sSearch'));
                     }
                     // Check if the database driver is PostgreSQL
                     // If it is, cast the current column to TEXT datatype
                     $cast_begin = null;
                     $cast_end = null;
                     if (DB::getDriverName() === 'pgsql') {
                         $cast_begin = "CAST(";
                         $cast_end = " as TEXT)";
                     }
                     $column = $db_prefix . $column;
                     if (Config::get('datatables.search.case_insensitive', false)) {
                         $query->orwhere(DB::raw('LOWER(' . $cast_begin . $column . $cast_end . ')'), 'LIKE', strtolower($keyword));
                     } else {
                         $query->orwhere(DB::raw($cast_begin . $column . $cast_end), 'LIKE', $keyword);
                     }
                 }
             }
         });
     }
     $db_prefix = $this->database_prefix();
     for ($i = 0, $c = count($columns); $i < $c; $i++) {
         if (Input::get('bSearchable_' . $i) == "true" && Input::get('sSearch_' . $i) != '') {
             $keyword = '%' . Input::get('sSearch_' . $i) . '%';
             if (Config::get('datatables.search.use_wildcards', false)) {
                 $keyword = $copy_this->wildcard_like_string(Input::get('sSearch_' . $i));
             }
             if (Config::get('datatables.search.case_insensitive', false)) {
                 $column = $db_prefix . $columns[$i];
                 $this->query->where(DB::raw('LOWER(' . $column . ')'), 'LIKE', strtolower($keyword));
             } else {
                 $col = strstr($columns[$i], '(') ? DB::raw($columns[$i]) : $columns[$i];
                 $this->query->where($col, 'LIKE', $keyword);
             }
         }
     }
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:58,代码来源:Datatables.php

示例3: setForeignKeyChecks

 protected function setForeignKeyChecks($enable = false)
 {
     switch (DB::getDriverName()) {
         case 'mysql':
             $status = $enable ? 1 : 0;
             DB::statement("SET FOREIGN_KEY_CHECKS={$status};");
             break;
         case 'sqlite':
             $status = $enable ? 'ON' : 'OFF';
             DB::statement("PRAGMA foreign_keys = {$status}");
             break;
     }
 }
开发者ID:mayconbordin,项目名称:l5-fixtures,代码行数:13,代码来源:Fixtures.php

示例4: getAllTables

 /**
  * Get all the tables present in the database
  * @param  string $dbname The name of the database
  * @return array          An array of table names present
  */
 protected function getAllTables($dbname)
 {
     $tables = array();
     if (DB::getDriverName() === 'mysql') {
         $tableRows = DB::select('SHOW tables');
         $column = "Tables_in_{$dbname}";
         foreach ($tableRows as $row) {
             $tables[] = $row->{$column};
         }
     } else {
         if (DB::getDriverName() === 'pgsql') {
             $tableRows = DB::select("SELECT table_name FROM information_schema.tables\n                  WHERE table_type = 'BASE TABLE'\n                  AND table_schema = 'public'\n                  ORDER BY table_type, table_name");
             foreach ($tableRows as $row) {
                 $tables[] = $row->table_name;
             }
         }
     }
     return $tables;
 }
开发者ID:bogdananton,项目名称:larry,代码行数:24,代码来源:GenerateFromDb.php

示例5: exportAllTranslations

 public function exportAllTranslations()
 {
     $select = '';
     switch (DB::getDriverName()) {
         case 'mysql':
             $select = 'DISTINCT `group`';
             break;
         default:
             $select = 'DISTINCT "group"';
             break;
     }
     $groups = Translation::whereNotNull('value')->select(DB::raw($select))->get('group');
     foreach ($groups as $group) {
         $this->exportTranslations($group->group);
     }
 }
开发者ID:barryvdh,项目名称:laravel-translation-manager,代码行数:16,代码来源:Manager.php

示例6: insertEntries

 /**
  * Insert entries in a table
  *
  * @param string $table
  * @param array  $entries
  */
 protected function insertEntries($table, $entries)
 {
     $slices = array($entries);
     // If the engine is SQLite and we have a lot of seeded entries
     // We'll split the results to not overflow the variable limit
     if (DB::getDriverName() === 'sqlite') {
         $slicer = floor(999 / sizeof($entries[0]));
         $slices = array_chunk($entries, $slicer);
     }
     if ($this->command) {
         $this->command->comment('Insert entries');
     }
     $this->progressIterator($slices, function ($entries) use($table) {
         DB::table($table)->insert($entries);
     });
 }
开发者ID:anahkiasen,项目名称:fakable,代码行数:22,代码来源:Fakable.php

示例7: filtering

 /**
  * Datatable filtering
  *
  * @return null
  */
 protected function filtering()
 {
     // copy of $this->columns without columns removed by remove_column
     $columns_copy = $this->columns;
     for ($i = 0, $c = count($columns_copy); $i < $c; $i++) {
         if (in_array($this->getColumnName($columns_copy[$i]), $this->excess_columns)) {
             unset($columns_copy[$i]);
         }
     }
     $columns_copy = array_values($columns_copy);
     // copy of $this->columns cleaned for database queries
     $columns_clean = $this->clean_columns($columns_copy, false);
     $columns_copy = $this->clean_columns($columns_copy, true);
     // global search
     if ($this->input['search']['value'] != '') {
         $_this = $this;
         $this->query->where(function ($query) use(&$_this, $columns_copy, $columns_clean) {
             $db_prefix = $_this->database_prefix();
             for ($i = 0, $c = count($_this->input['columns']); $i < $c; $i++) {
                 if (isset($columns_copy[$i]) && $_this->input['columns'][$i]['searchable'] == "true") {
                     // if filter column exists for this columns then use user defined method
                     if (isset($_this->filter_columns[$columns_copy[$i]])) {
                         // check if "or" equivalent exists for given function
                         // and if the number of parameters given is not excess
                         // than call the "or" equivalent
                         $method_name = 'or' . ucfirst($_this->filter_columns[$columns_copy[$i]]['method']);
                         if (method_exists($query->getQuery(), $method_name) && count($_this->filter_columns[$columns_copy[$i]]['parameters']) <= with(new \ReflectionMethod($query->getQuery(), $method_name))->getNumberOfParameters()) {
                             call_user_func_array(array($query, $method_name), $_this->inject_variable($_this->filter_columns[$columns_copy[$i]]['parameters'], $_this->input['search']['value']));
                         }
                     } else {
                         $keyword = '%' . $_this->input['search']['value'] . '%';
                         if (Config::get('datatables::search.use_wildcards', false)) {
                             $keyword = $_this->wildcard_like_string($_this->input['search']['value']);
                         }
                         // Check if the database driver is PostgreSQL
                         // If it is, cast the current column to TEXT datatype
                         $cast_begin = null;
                         $cast_end = null;
                         if (DB::getDriverName() === 'pgsql') {
                             $cast_begin = "CAST(";
                             $cast_end = " as TEXT)";
                         }
                         $column = $db_prefix . $columns_clean[$i];
                         if (Config::get('datatables::search.case_insensitive', false)) {
                             $query->orwhere(DB::raw('LOWER(' . $cast_begin . $column . $cast_end . ')'), 'LIKE', strtolower($keyword));
                         } else {
                             $query->orwhere(DB::raw($cast_begin . $column . $cast_end), 'LIKE', $keyword);
                         }
                     }
                 }
             }
         });
     }
     $db_prefix = $this->database_prefix();
     // column search
     for ($i = 0, $c = count($this->input['columns']); $i < $c; $i++) {
         if (isset($columns_copy[$i]) && $this->input['columns'][$i]['orderable'] == "true" && $this->input['columns'][$i]['search']['value'] != '') {
             // if filter column exists for this columns then use user defined method
             if (isset($this->filter_columns[$columns_copy[$i]])) {
                 call_user_func_array(array($this->query, $this->filter_columns[$columns_copy[$i]]['method']), $this->inject_variable($this->filter_columns[$columns_copy[$i]]['parameters'], $this->input['columns'][$i]['search']['value']));
             } else {
                 $keyword = '%' . $this->input['columns'][$i]['search']['value'] . '%';
                 if (Config::get('datatables::search.use_wildcards', false)) {
                     $keyword = $this->wildcard_like_string($this->input['columns'][$i]['search']['value']);
                 }
                 if (Config::get('datatables::search.case_insensitive', false)) {
                     $column = $db_prefix . $columns_clean[$i];
                     $this->query->where(DB::raw('LOWER(' . $column . ')'), 'LIKE', strtolower($keyword));
                 } else {
                     $col = strstr($columns_clean[$i], '(') ? DB::raw($columns_clean[$i]) : $columns_clean[$i];
                     $this->query->where($col, 'LIKE', $keyword);
                 }
             }
         }
     }
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:81,代码来源:Datatables.php


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