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


PHP Field::query方法代码示例

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


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

示例1: process

 function process()
 {
     header("Content-type: text/xml");
     $this->template_name = 'pages/gmaps/allfields.tpl';
     $sth = Field::query(array('_extra' => 'ISNULL(f.parent_fid) AND f.status = "open"', '_order' => 'f.fid'));
     $fields = array();
     while ($field = $sth->fetchObject('Field')) {
         if (!$field->latitude || !$field->longitude) {
             continue;
         }
         $fields[] = $field;
     }
     $this->smarty->assign('fields', $fields);
 }
开发者ID:roboshed,项目名称:leaguerunner,代码行数:14,代码来源:allfields.php

示例2: process

 function process()
 {
     $this->title = "{$this->league->fullname} » Status Report";
     $this->template_name = 'pages/league/status.tpl';
     // make sure the teams are loaded
     $this->league->load_teams();
     // TODO: we calculate_standings() here, but it's probably not necessary
     list($order, $season, $round) = $this->league->calculate_standings(array('round' => $this->league->current_round));
     $fields = array();
     $sth = Field::query(array('_extra' => '1 = 1', '_order' => 'f.code'));
     while ($field = $sth->fetchObject('Field')) {
         $fields[$field->code] = $field->region;
     }
     // Parse the schedule and accumulate per-team stats
     $sth = Game::query(array('league_id' => $this->league->league_id, '_order' => 'g.game_date, g.game_start, field_code'));
     while ($g = $sth->fetchObject('Game')) {
         $season[$g->home_team]->game_count++;
         $season[$g->away_team]->game_count++;
         list($code, $num) = explode(' ', $g->field_code);
         $season[$g->home_team]->region_game_counts[$fields[$code]]++;
         $season[$g->away_team]->region_game_counts[$fields[$code]]++;
         $season[$g->home_team]->home_game_count++;
         $season[$g->home_team]->opponent_counts[$g->away_name]++;
         $season[$g->away_team]->opponent_counts[$g->home_name]++;
     }
     $teams = array();
     while (list(, $tid) = each($order)) {
         $team = $season[$tid];
         $ratio = $team->preferred_field_ratio();
         if ($ratio > 1) {
             # If ratio is > 1, lower it to 1 for display purposes
             $ratio = 1;
         }
         $ratio = sprintf("%.3f", $ratio);
         $check_ratio = $ratio;
         if ($team->game_count % 2) {
             $check_ratio = ($ratio * $team->game_count + 1) / ($team->game_count + 1);
         }
         list($team->preferred_ratio, $team->preferred_ratio_bad) = array($ratio, $check_ratio < 0.5);
         list($team->home_game_ratio, $team->home_game_ratio_bad) = _ratio_helper($team->home_game_count, $team->game_count);
         $teams[] = $team;
     }
     $this->smarty->assign('teams', $teams);
     return true;
 }
开发者ID:roboshed,项目名称:leaguerunner,代码行数:45,代码来源:status.php

示例3: generateForm

 function generateForm(&$edit)
 {
     $this->smarty->assign('field_statuses', array('open' => 'open', 'closed' => 'closed'));
     $this->smarty->assign('ratings', field_rating_values());
     // TODO: Should become Field::get_eligible_parents()
     $sth = Field::query(array('_extra' => 'ISNULL(parent_fid)', '_order' => 'f.name,f.num'));
     $parents = array();
     $parents[0] = "---";
     while ($p = $sth->fetch(PDO::FETCH_OBJ)) {
         $parents[$p->fid] = $p->fullname;
     }
     $this->smarty->assign('parents', $parents);
     $this->smarty->assign('regions', getOptionsFromEnum('field', 'region'));
     $this->smarty->assign('noyes', array(0 => 'No', 1 => 'Yes'));
     $this->smarty->assign('province_names', getProvinceNames());
     $this->smarty->assign('state_names', getStateNames());
     $this->smarty->assign('country_names', getCountryNames());
     return true;
 }
开发者ID:h07r0d,项目名称:leaguerunner,代码行数:19,代码来源:edit.php

示例4: process

 function process()
 {
     global $lr_session;
     $this->template_name = 'pages/field/list.tpl';
     $this->title = 'List Fields';
     if ($lr_session->has_permission('field', 'list', 'closed')) {
         $status = '';
     } else {
         $status = "AND (status = 'open' OR ISNULL(status))";
     }
     $sth = Field::query(array('_extra' => "ISNULL(parent_fid) {$status}", '_order' => 'f.region,f.name'));
     $fields = array();
     while ($field = $sth->fetch(PDO::FETCH_OBJ)) {
         if (!array_key_exists($field->region, $fields)) {
             $fields[$field->region] = array();
         }
         array_push($fields[$field->region], $field);
     }
     $this->smarty->assign('fields_by_region', $fields);
     return true;
 }
开发者ID:roboshed,项目名称:leaguerunner,代码行数:21,代码来源:list.php

示例5: generateForm

 function generateForm($data = array())
 {
     $output = form_hidden("edit[step]", "confirm");
     $output .= form_textfield("Field Identification", 'edit[num]', $data['num'], 15, 15, "Location of this field at the given site; cannot be 0");
     $output .= form_select("Field Status", 'edit[status]', $data['status'], array('open' => 'open', 'closed' => 'closed'));
     $output .= form_select("Field Rating", 'edit[rating]', $data['rating'], field_rating_values(), "Rate this field on the scale provided");
     // TODO: Should become Field::get_eligible_parents()
     $sth = Field::query(array('_extra' => 'ISNULL(parent_fid)', '_order' => 'f.name,f.num'));
     $parents = array();
     $parents[0] = "---";
     while ($p = $sth->fetch(PDO::FETCH_OBJ)) {
         $parents[$p->fid] = $p->fullname;
     }
     $output .= form_select("Parent Field", 'edit[parent_fid]', $data['parent_fid'], $parents, "Inherit location and name from other field");
     if (!$data['parent_fid']) {
         $output .= form_textfield("Field Name", 'edit[name]', $data['name'], 35, 255, "Name of field (do not append number)");
         $output .= form_textfield("Field Code", 'edit[code]', $data['code'], 3, 3, "Three-letter abbreviation for field site");
         $output .= form_select("Region", 'edit[region]', $data['region'], getOptionsFromEnum('field', 'region'), "Area of city this field is located in");
         $output .= form_select("Is indoor", 'edit[is_indoor]', $data['is_indoor'], array(0 => 'No', 1 => 'Yes'), "Is this an indoor field");
         $output .= form_textfield('Street and Number', 'edit[location_street]', $data['location_street'], 25, 100);
         $output .= form_textfield('City', 'edit[location_city]', $data['location_city'], 25, 100, 'Name of city');
         $output .= form_select('Province', 'edit[location_province]', $data['location_province'], getProvinceNames(), 'Select a province from the list');
         $output .= form_textfield("Location Map", 'edit[location_url]', $data['location_url'], 50, 255, "URL for image that shows how to reach the field");
         $output .= form_textfield("Layout Map", 'edit[layout_url]', $data['layout_url'], 50, 255, "URL for image that shows how to set up fields at the site");
         $output .= form_textarea("Driving Directions", 'edit[driving_directions]', $data['driving_directions'], 60, 5, "");
         $output .= form_textarea("Parking Details", 'edit[parking_details]', $data['parking_details'], 60, 5, "");
         $output .= form_textarea("Transit Directions", 'edit[transit_directions]', $data['transit_directions'], 60, 5, "");
         $output .= form_textarea("Biking Directions", 'edit[biking_directions]', $data['biking_directions'], 60, 5, "");
         $output .= form_textarea("Public Washrooms", 'edit[washrooms]', $data['washrooms'], 60, 5, "");
         $output .= form_textarea("Special Instructions", 'edit[public_instructions]', $data['public_instructions'], 60, 5, "Specific instructions for this site that don't fit any other category.");
         $output .= form_textarea("Private Instructions", 'edit[site_instructions]', $data['site_instructions'], 60, 5, "Instructions for this site that should be shown only to logged-in members.");
         $output .= form_textarea("Sponsorship", 'edit[sponsor]', $data['sponsor'], 60, 5, "");
     }
     $output .= form_submit('Submit') . form_reset('Reset');
     return form($output);
 }
开发者ID:roboshed,项目名称:leaguerunner,代码行数:36,代码来源:edit.php

示例6: generateStatusPage

    function generateStatusPage()
    {
        global $dbh;
        // make sure the teams are loaded
        $this->league->load_teams();
        list($order, $season, $round) = $this->league->calculate_standings(array('round' => $this->league->current_round));
        $fields = array();
        $sth = Field::query(array('_order' => 'f.code'));
        while ($field = $sth->fetchObject('Field')) {
            $fields[$field->code] = $field->region;
        }
        $output = para("This is a general field scheduling balance report for the league. The first number in each cell is the number of games that team has played at a given site.  The second number, in brackets, is the team's average ranking for that site.  Zero represents an unranked field.");
        $num_teams = sizeof($order);
        $header[] = array('data' => "Rating", 'rowspan' => 2);
        $header[] = array('data' => "Team", 'rowspan' => 2);
        // now gather all possible fields this league can use
        $sth = $dbh->prepare('SELECT
				DISTINCT IF(f.parent_fid, pf.code, f.code) AS field_code,
				TIME_FORMAT(g.game_start, "%H:%i") as game_start,
				IF(f.parent_fid, pf.region, f.region) AS field_region,
				IF(f.parent_fid, pf.fid, f.fid) AS fid,
				IF(f.parent_fid, pf.name, f.name) AS name
			FROM league_gameslot_availability a
			INNER JOIN gameslot g ON (g.slot_id = a.slot_id)
			LEFT JOIN field f ON (f.fid = g.fid)
			LEFT JOIN field pf ON (pf.fid = f.parent_fid)
			WHERE a.league_id = ?
			ORDER BY field_region DESC, field_code, game_start');
        $sth->execute(array($this->league->league_id));
        $last_region = "";
        $field_region_count = 0;
        while ($row = $sth->fetch(PDO::FETCH_OBJ)) {
            $field_list[] = "{$row->field_code} {$row->game_start}";
            $subheader[] = array('data' => l($row->field_code, "field/view/{$row->fid}", array('title' => $row->name)) . " {$row->game_start}", 'class' => "subtitle");
            if ($last_region == $row->field_region) {
                $field_region_count++;
            } else {
                if ($field_region_count > 0) {
                    $header[] = array('data' => $last_region, 'colspan' => $field_region_count);
                }
                $last_region = $row->field_region;
                $field_region_count = 1;
            }
        }
        // and make the last region header too
        if ($field_region_count > 0) {
            $header[] = array('data' => $last_region, 'colspan' => $field_region_count);
        }
        $header[] = array('data' => "Games", 'rowspan' => 2);
        $rows = array();
        $rows[] = $subheader;
        $rowstyle = "standings_light";
        // get the schedule
        $schedule = array();
        $sth = Game::query(array('league_id' => $this->league->league_id, '_order' => 'g.game_date, g.game_start, field_code'));
        while ($g = $sth->fetchObject('Game')) {
            $schedule[] = $g;
        }
        // we'll cache these results, so we can compute avgs and highlight numbers too far from average
        $cache_rows = array();
        $total_at_field = array();
        $sum_field_rankings = array();
        while (list(, $tid) = each($order)) {
            if ($rowstyle == "standings_light") {
                $rowstyle = "standings_dark";
            } else {
                $rowstyle = "standings_light";
            }
            $row = array(array('data' => $season[$tid]->rating, 'class' => "{$rowstyle}"));
            $row[] = array('data' => l($season[$tid]->name, "team/view/{$tid}"), 'class' => "{$rowstyle}");
            // count number of games per field for this team:
            $numgames = 0;
            $count = array();
            $site_ranks = array();
            // parse the schedule
            reset($schedule);
            while (list(, $game) = each($schedule)) {
                if ($game->home_team == $tid || $game->away_team == $tid) {
                    $numgames++;
                    list($code, $num) = explode(' ', $game->field_code);
                    $count["{$code} {$game->game_start}"]++;
                    $rank = $game->get_site_ranking($tid);
                    if ($rank != 'unranked') {
                        $site_ranks["{$code} {$game->game_start}"] += $rank;
                    }
                }
            }
            foreach ($field_list as $f) {
                $thisrow = array('data' => "0", 'class' => "{$rowstyle}", 'align' => 'center');
                if ($count[$f]) {
                    $thisrow['data'] = $count[$f] . sprintf(' (%.3f)', $site_ranks[$f] / $count[$f]);
                    $total_at_field[$f] += $count[$f];
                    $sum_field_ranks[$f] += $site_ranks[$f];
                }
                $row[] = $thisrow;
            }
            $row[] = array('data' => $numgames, 'class' => "{$rowstyle}", 'align' => "center");
            $cache_rows[] = $row;
        }
        // pass through cached rows and highlight entries far from avg
//.........这里部分代码省略.........
开发者ID:roboshed,项目名称:leaguerunner,代码行数:101,代码来源:fields.php


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