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


PHP Manager::select方法代码示例

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


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

示例1: checkConnection

 /**
  * check database connection based on provided setting
  */
 public function checkConnection()
 {
     $success = false;
     $message = '';
     $config = $this->getPostConfiguration();
     try {
         $this->makeConnection($config);
         /**
          * Just trying to show tables with current connection
          */
         switch ($config['driver']) {
             case 'mysql':
                 $tables = Capsule::select('show tables');
                 break;
             case 'sqlite':
                 $tables = Capsule::select("SELECT * FROM sqlite_master WHERE type='table'");
                 break;
             case 'sqlsrv':
                 $tables = Capsule::select("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'");
                 break;
             case 'pgsql':
                 $tables = Capsule::select("SELECT * FROM pg_catalog.pg_tables");
                 break;
         }
         $success = true;
         $message = 'Successfully connected!';
     } catch (Exception $e) {
         $success = false;
         $message = $e->getMessage();
     }
     Response::headers()->set('Content-Type', 'application/json');
     Response::setBody(json_encode(array('success' => $success, 'message' => $message, 'config' => $config)));
 }
开发者ID:lupuxyz,项目名称:SlimStarter,代码行数:36,代码来源:InstallController.php

示例2: getSectorEmpresas

 function getSectorEmpresas(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = Parametros::select("*")->first();
     $km = $data["diametro_busqueda"];
     $idSector = $request->getAttribute("id");
     $lat = $request->getAttribute("latitud");
     $lng = $request->getAttribute("longitud");
     $query = "SELECT " . "(6371 * ACOS( SIN(RADIANS(su.latitud)) * SIN(RADIANS({$lat})) + COS(RADIANS(su.longitud - {$lng})) * " . "COS(RADIANS(su.latitud)) * COS(RADIANS({$lat})))) AS distancia, " . "em.id, " . "em.nit, " . "em.razonSocial, " . "em.logo, " . "'' as servicios " . "FROM sucursal su " . "INNER JOIN " . "empresa em ON (em.id = su.idEmpresa) " . "INNER JOIN " . "sectorempresa secemp ON (secemp.idEmpresa = em.id && secemp.idSector =  {$idSector}) " . "WHERE su.Estado = 'ACTIVO' AND em.estado = 'ACTIVO' " . "HAVING distancia < {$km} ORDER BY distancia ASC";
     $data = DB::select(DB::raw($query));
     for ($i = 0; $i < count($data); $i++) {
         $val = "";
         $ser = Servicio::select("nombre")->where("idEmpresa", "=", $data[$i]->id)->get();
         $tam = count($ser);
         for ($j = 0; $j < $tam; $j++) {
             $val .= $ser[$j]->nombre;
             if ($j + 1 < $tam) {
                 $val .= ",";
             }
         }
         $data[$i]->servicios = $val;
     }
     $response->getBody()->write(json_encode($data));
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:25,代码来源:SectorControl.php

示例3: index

 public function index()
 {
     $season = $_REQUEST['season'] ?: $this->season;
     $activity = $_REQUEST['activity'] ?: 'Poker';
     $venue_id = $_REQUEST['venue_id'] ?: League::where('season', $season)->where('activity', $activity)->value('venue_id');
     $league = League::where('season', $season)->where('activity', $activity)->where('venue_id', $venue_id)->first();
     if (!$league->id) {
         $_SESSION['ALERT'] = alert("No League Found!", "There were no leagues found matching the specified parameters.", "warning");
         return sizeof($_REQUEST) ? redirect("/rankings") : redirect("/");
     }
     $rankings_query = ' select s.player_id as id, concat(p.lastname, ", ", p.forename) as name, concat(p.forename, " ", p.lastname) as fullname, count(*) as games, sum(s.points) as total ';
     $rankings_query .= ' from t_scores s ';
     $rankings_query .= ' join t_events e on e.id = s.event_id ';
     $rankings_query .= ' join t_players p on p.id = s.player_id ';
     $rankings_query .= ' where e.league_id=? ';
     $rankings_query .= ' group by s.player_id ';
     $rankings = DB::select($rankings_query, [$league->id]);
     $points_query = ' select points ';
     $points_query .= ' from t_scores ';
     $points_query .= ' where player_id=? ';
     $points_query .= ' and event_id in ( ';
     $points_query .= ' select id ';
     $points_query .= ' from t_events ';
     $points_query .= ' where league_id=? ';
     $points_query .= ' ) ';
     $points_query .= ' order by points desc ';
     $points_query .= ' limit ' . $league->ranked_at;
     array_walk($rankings, function (&$ranking) use($points_query, $league) {
         $ranking->points = DB::select($points_query, [$ranking->id, $league->id]);
         $ranking->points = array_map(function ($p) {
             return $p->points;
         }, $ranking->points);
         $ranking->value = $ranking->games >= $league->ranked_at ? $league->ranking == 'AVG' ? floor(array_sum($ranking->points) / $league->ranked_at) : array_sum($ranking->points) : -1;
     });
     $ranked = array_filter($rankings, function ($ranking) {
         return $ranking->value !== -1;
     });
     usort($ranked, function ($a, $b) {
         return $b->value - $a->value;
     });
     $unranked = array_filter($rankings, function ($ranking) {
         return $ranking->value === -1;
     });
     usort($unranked, function ($a, $b) {
         return $b->total - $a->total;
     });
     $seasonPointsLeaders = array_filter($rankings, function ($ranking) {
         return $ranking->total > 0;
     });
     usort($seasonPointsLeaders, function ($a, $b) {
         return $b->total - $a->total;
     });
     $seasonPointsLeaders = array_slice($seasonPointsLeaders, 0, 1);
     $wildCardWinners = User::whereHas('scores', function ($query) use($league) {
         $query->where('finished', '1')->whereHas('event', function ($query) use($league) {
             $query->where('league_id', $league->id)->where('week_num', 'Wild Card');
         });
     })->get();
     return view('pages.rankings', compact('league', 'ranked', 'unranked', 'seasonPointsLeaders', 'wildCardWinners'));
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:60,代码来源:RankingsController.php

示例4: storeFull

 protected function storeFull($json)
 {
     $categories = json_decode($json, true);
     // grab categories from the database
     $dbCategories = collect(DB::table('categories')->get(['cSlug']))->keyBy('cSlug')->toArray();
     // grab an array of columns in the categories table
     $columns = DB::select('select COLUMN_NAME as `column` from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \'fmtc_categories\'');
     // set the counters for reporting
     $insertCount = 0;
     $removeCount = 0;
     // walk through the categories from a merchant feed
     $jsonCategoryIds = [];
     foreach ($categories as $category) {
         // is the category missing from the database?
         if (!isset($dbCategories[$category['cSlug']])) {
             // insert it (this is faster than building an insert queue and bulk inserting)
             DB::table('categories')->insert($this->formatForInsertion($category, $columns));
             $insertCount++;
         }
         // collect an array of ids to aid in the remove	queue
         $jsonCategoryIds[] = $category['cSlug'];
     }
     // remove old categories showing up in the database but not in the new merchant feed.
     $removeQueue = array_diff(array_keys($dbCategories), $jsonCategoryIds);
     $removeCount = count($removeQueue);
     foreach ($removeQueue as $categoryId) {
         DB::table('categories')->where('cSlug', $categoryId)->delete();
     }
     //---- debugging
     // debug($removeCount . ' removed');
     // debug($insertCount . ' inserted');
     //-----
     return true;
 }
开发者ID:calebporzio,项目名称:fmtc-php,代码行数:34,代码来源:CategoryFeed.php

示例5: getData

 function getData()
 {
     $query = 'Select * from ' . $this->table;
     $data = Capsule::select($query);
     return json_encode($data);
     //return $data;
 }
开发者ID:elbajuri,项目名称:ketupat,代码行数:7,代码来源:c_user.php

示例6: getSchema

 /**
  * @return bool
  */
 public function getSchema()
 {
     if (!$this->hasTable()) {
         return false;
     }
     $colums = Capsule::select("SHOW COLUMNS FROM {$this->tableName}");
     return $colums;
 }
开发者ID:ncrousset,项目名称:gencrud,代码行数:11,代码来源:TableSchema.php

示例7: promedio

 public function promedio(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $idCliente = $request->getAttribute("idCliente");
     $query = "SELECT COALESCE(AVG(calificacion),0) as promedio FROM calificacioncliente WHERE idCliente = " . $idCliente;
     $data = DB::select(DB::raw($query));
     $response->getBody()->write(json_encode($data));
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:9,代码来源:CalificacionClienteControl.php

示例8: getNeighbourChurches

 function getNeighbourChurches()
 {
     $neighbours = DB::select("SELECT d.distance tavolsag,t.nev,t.ismertnev,t.varos,t.id tid FROM distance as d\n            LEFT JOIN templomok as t ON (tid1 <> :tid1 AND tid1 = id ) OR (tid2 <> :tid2 AND tid2 = id )\n            WHERE ( tid1 = :tid3 OR tid2 = :tid4 ) AND distance <= 10000 \n            AND t.id IS NOT NULL \n            ORDER BY distance ", ['tid1' => $this->id, 'tid2' => $this->id, 'tid3' => $this->id, 'tid4' => $this->id]);
     $this->neigbourChurches = (array) $neighbours;
     if (!isset($this->neigbourChurches)) {
         $neighbours = DB::select("SELECT d.distance tavolsag,t.nev,t.ismertnev,t.varos,t.id tid FROM distance as d\n                LEFT JOIN templomok as t ON (tid1 <> :tid1 AND tid1 = id ) OR (tid2 <> :tid2 AND tid2 = id )\n                WHERE ( tid1 = :tid3 OR tid2 = :tid4 )\n                ORDER BY distance \n                LIMIT 1", ['tid1' => $this->id, 'tid2' => $this->id, 'tid3' => $this->id, 'tid4' => $this->id]);
         $this->neigbourChurches = (array) $neighbours;
     }
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:9,代码来源:Church.php

示例9: contasector

 function contasector(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     //sum(ingresos.valor) as total,
     $id = $request->getAttribute("idSector");
     $fechainicial = $request->getAttribute("fechainicial");
     $fechafinal = $request->getAttribute("fechafinal");
     $data = DB::select(DB::raw("select sum(ingresos.valor) as total,ingresos.fecha,sectorempresa.id," . "empresa.razonSocial,sucursal.nombre" . " from sectorempresa " . "inner join empresa on empresa.id = sectorempresa.idEmpresa " . "inner join sucursal on sucursal.idEmpresa = empresa.id " . "inner join empleado on empleado.idSucursal = sucursal.id " . "inner join ingresos on ingresos.idEmpleado = empleado.id " . "where sectorempresa.idSector = " . $id . " and ingresos.fecha BETWEEN '" . $fechainicial . "' and " . "'" . $fechafinal . "' " . "GROUP BY empresa.razonSocial"));
     $response->getBody()->write(json_encode($data));
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:11,代码来源:SectorEmpresaControl.php

示例10: show

 public function show($id)
 {
     $category = $this->categories[$id - 1];
     $query = " select player_id as id, player_fullname as fullname, {{ query }} as value ";
     $query .= " from v_player_stats where activity = 'Poker' and total_games > 96 ";
     $query .= " order by {{ field }} desc limit 3 ";
     $query = str_replace('{{ query }}', $category->query, $query);
     $query = str_replace('{{ field }}', $category->field, $query);
     $players = DB::select($query);
     return sizeof($players) ? view('hall-of-fame.show', compact('players')) : '<div class="hof-loading"><em>No Scores Found...</em></div>';
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:11,代码来源:HallOfFameController.php

示例11: show

 public function show($id = null)
 {
     if (!$id) {
         $id = Auth::user()->id;
     }
     if (!$id) {
         redirect('/auth/login');
     }
     $user = User::findOrFail($id);
     $stats = DB::select('select * from v_player_stats where player_id = ?', [$user->id]);
     return view('users.show', compact('user', 'stats'));
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:12,代码来源:UsersController.php

示例12: get

 public function get()
 {
     $user_id = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0;
     $depth = isset($_GET['depth']) ? (int) $_GET['depth'] : 1;
     if ($user_id == 0 or $depth == 0) {
         echo json_encode([]);
         return;
     }
     $fields = ['level1.user_id AS user', 'level1.friend_id AS friend'];
     $joins = [];
     if ($depth > 1) {
         foreach (range(2, $depth) as $l) {
             $fields[] = 'level' . $l . '.friend_id AS mutual' . ($l - 1);
             $joins[] = 'LEFT JOIN friends level' . $l . ' ON (level' . ($l - 1) . '.`friend_id` = level' . $l . '.`user_id` AND level' . $l . '.`friend_id` != level' . ($l - 1) . '.`user_id`)';
         }
     }
     $query = 'SELECT ';
     $query .= implode(',', $fields);
     $query .= ' FROM friends level1 ';
     $query .= implode(' ', $joins);
     $query .= ' WHERE level1.user_id = ' . $user_id;
     $user_ids = [];
     $records = json_decode(json_encode(DB::select($query)), true);
     foreach ($records as $r => $record) {
         foreach ($record as $key => $id) {
             $id = (int) $id;
             if (!($id > 0)) {
                 unset($records[$r][$key]);
                 continue;
             }
             if (in_array($id, $user_ids)) {
                 continue;
             }
             $user_ids[] = $id;
         }
     }
     $Users = User::whereIn('id', $user_ids)->get();
     $users = [];
     foreach ($Users as $User) {
         $users[$User->id] = $User->toArray();
     }
     foreach ($records as $r => $record) {
         foreach ($record as $key => $id) {
             $id = (int) $id;
             if (!($id > 0)) {
                 continue;
             }
             $records[$r][$key] = $users[$id];
         }
     }
     echo json_encode($records);
 }
开发者ID:num8er,项目名称:techery_test,代码行数:52,代码来源:FriendsController.php

示例13: getRegisteredEventsAttribute

 public function getRegisteredEventsAttribute()
 {
     $schedule_query = ' select e.id, e.activity, v.fullname as venue, e.datetime ';
     $schedule_query .= ' from t_scores s ';
     $schedule_query .= ' left join t_events e on e.id = s.event_id ';
     $schedule_query .= ' left join t_venues v on v.id = e.venue_id ';
     $schedule_query .= ' where s.player_id = ? and e.datetime >= ? ';
     $schedule_query .= ' order by week_num, venue_id, datetime asc ';
     $events = DB::select($schedule_query, [$this->id, date('Y-m-d')]);
     return array_map(function ($event) {
         return Event::find($event->id);
     }, $events);
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:13,代码来源:User.php

示例14: storeIncremental

 protected function storeIncremental($json)
 {
     $deals = json_decode($json, true);
     // grab deals from the database
     $dbDealsRows = DB::table('deals')->get(['nCouponID', 'cLastUpdated']);
     foreach ($dbDealsRows as $row) {
         $dbDeals[$row->nCouponID] = $row;
     }
     // grab an array of columns in the deals table
     $columns = DB::select('select COLUMN_NAME as `column` from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \'fmtc_deals\'');
     // set the counters for reporting
     $insertCount = 0;
     $updateCount = 0;
     $removeCount = 0;
     // walk through the deals from a deal feed
     foreach ($deals as $deal) {
         // is this deal in the database?
         if (isset($dbDeals[$deal['nCouponID']])) {
             // is it active?
             if ($deal['cStatus'] == 'active') {
                 // has it been updated
                 if ($dbDeals[$deal['nCouponID']]->cLastUpdated != $deal['cLastUpdated']) {
                     // update it
                     $this->updateDeal($deal, $columns);
                     $updateCount++;
                 }
             } else {
                 // if it's not active remove it
                 $this->removeDeal($deal['nCouponID']);
                 $removeCount++;
             }
         } else {
             // make sure it's active
             if ($deal['cStatus'] == 'active') {
                 // insert it (this is faster than building an insert queue and bulk inserting)
                 $this->insertDeal($deal, $columns);
                 $insertCount++;
             }
         }
     }
     //---- debugging
     // debug($removeCount . ' removed');
     // debug($insertCount . ' inserted');
     // debug($updateCount . ' updated');
     //-----
     return true;
 }
开发者ID:FMTCco,项目名称:fmtc-php,代码行数:47,代码来源:DealFeed.php

示例15: checkConnection

 /**
  * check database connection based on provided setting
  */
 public function checkConnection()
 {
     $success = false;
     $message = '';
     $config = $this->getPostConfiguration();
     try {
         $this->makeConnection($config);
         $tables = Capsule::select('show tables');
         $success = true;
         $message = 'Successfully connected!';
     } catch (Exception $e) {
         $success = false;
         $message = $e->getMessage();
     }
     Response::headers()->set('Content-Type', 'application/json');
     Response::setBody(json_encode(array('success' => $success, 'message' => $message, 'config' => $config)));
 }
开发者ID:acmadi,项目名称:SlimStarter,代码行数:20,代码来源:InstallController.php


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