本文整理汇总了PHP中okapi\Db::select_group_by方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::select_group_by方法的具体用法?PHP Db::select_group_by怎么用?PHP Db::select_group_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类okapi\Db
的用法示例。
在下文中一共展示了Db::select_group_by方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_gpx
//.........这里部分代码省略.........
$fields .= "|latest_logs";
}
if ($vars['mark_found']) {
$fields .= "|is_found";
}
$vars['caches'] = OkapiServiceRunner::call('services/caches/geocaches', new OkapiInternalRequest($request->consumer, $request->token, array('cache_codes' => $cache_codes, 'langpref' => $langpref, 'fields' => $fields, 'lpc' => $lpc, 'user_uuid' => $user_uuid, 'log_fields' => 'uuid|date|user|type|comment|internal_id|was_recommended')));
# Get rid of invalid cache references.
$valid = array();
foreach ($vars['caches'] as $key => &$ref) {
if ($ref !== null) {
$valid[$key] =& $ref;
}
}
$vars['caches'] =& $valid;
unset($valid);
# Get all the other data need.
$vars['installation'] = OkapiServiceRunner::call('services/apisrv/installation', new OkapiInternalRequest(new OkapiInternalConsumer(), null, array()));
$vars['cache_GPX_types'] = self::$cache_GPX_types;
$vars['cache_GPX_sizes'] = self::$cache_GPX_sizes;
if (count($vars['attrs']) > 0) {
/* The user asked for some kind of attribute output. We'll fetch all
* the data we MAY need. This is often far too much, but thanks to
* caching, it will work fast. */
$vars['attr_index'] = OkapiServiceRunner::call('services/attrs/attribute_index', new OkapiInternalRequest($request->consumer, $request->token, array('only_locally_used' => 'true', 'langpref' => $langpref, 'fields' => 'name|gc_equivs')));
# prepare GS attribute data
$vars['gc_attrs'] = in_array('gc:attrs', $vars['attrs']);
$vars['gc_ocde_attrs'] = in_array('gc_ocde:attrs', $vars['attrs']);
if ($vars['gc_attrs'] || $vars['gc_ocde_attrs']) {
if ($vars['gc_ocde_attrs']) {
# As this is an OCDE compatibility feature, we use the same Pseudo-GS
# attribute names here as OCDE. Note that this code is specific to OCDE
# database; OCPL stores attribute names in a different way and may use
# different names for equivalent attributes.
$ocde_attrnames = Db::select_group_by('id', "\n select id, name\n from cache_attrib\n ");
$attr_dict = AttrHelper::get_attrdict();
}
foreach ($vars['caches'] as &$cache_ref) {
$cache_ref['gc_attrs'] = array();
foreach ($cache_ref['attr_acodes'] as $acode) {
$has_gc_equivs = false;
foreach ($vars['attr_index'][$acode]['gc_equivs'] as $gc) {
# The assignment via GC-ID as array key will prohibit duplicate
# GC attributes, which can result from
# - assigning the same GC ID to multiple A-Codes,
# - contradicting attributes in one OC listing, e.g. 24/4 + not 24/7.
$cache_ref['gc_attrs'][$gc['id']] = $gc;
$has_gc_equivs = true;
}
if (!$has_gc_equivs && $vars['gc_ocde_attrs']) {
# Generate an OCDE pseudo-GS attribute;
# see https://github.com/opencaching/okapi/issues/190 and
# https://github.com/opencaching/okapi/issues/271.
#
# Groundspeak uses ID 1..65 (as of June, 2013), and OCDE makeshift
# IDs start at 106, so there is space for 40 new GS attributes.
$internal_id = $attr_dict[$acode]['internal_id'];
$cache_ref['gc_attrs'][100 + $internal_id] = array('inc' => 1, 'name' => $ocde_attrnames[$internal_id][0]['name']);
}
}
}
}
}
/* OC sites always used internal user_ids in their generated GPX files.
* This might be considered an error in itself (Groundspeak's XML namespace
* doesn't allow that), but it very common (Garmin's OpenCaching.COM
* also does that). Therefore, for backward-compatibility reasons, OKAPI
示例2: call
//.........这里部分代码省略.........
} else {
$result_ref['trackables_count'] = 0;
}
}
unset($tr_counts);
}
}
# Alternate/Additional waypoints.
if (in_array('alt_wpts', $fields)) {
$internal_wpt_type_id2names = array();
if (Settings::get('OC_BRANCH') == 'oc.de') {
$rs = Db::query("\n select\n ct.id,\n LOWER(stt.lang) as language,\n stt.`text`\n from\n coordinates_type ct\n left join sys_trans_text stt on stt.trans_id = ct.trans_id\n ");
while ($row = mysql_fetch_assoc($rs)) {
$internal_wpt_type_id2names[$row['id']][$row['language']] = $row['text'];
}
mysql_free_result($rs);
} else {
$rs = Db::query("\n select id, pl, en\n from waypoint_type\n where id > 0\n ");
while ($row = mysql_fetch_assoc($rs)) {
$internal_wpt_type_id2names[$row['id']]['pl'] = $row['pl'];
$internal_wpt_type_id2names[$row['id']]['en'] = $row['en'];
}
}
foreach ($results as &$result_ref) {
$result_ref['alt_wpts'] = array();
}
$cache_codes_escaped_and_imploded = "'" . implode("','", array_map('mysql_real_escape_string', array_keys($cacheid2wptcode))) . "'";
if (Settings::get('OC_BRANCH') == 'oc.pl') {
# OCPL uses 'waypoints' table to store additional waypoints and defines
# waypoint types in 'waypoint_type' table.
# OCPL also have a special 'status' field to denote a hidden waypoint
# (i.e. final location of a multicache). Such hidden waypoints are not
# exposed by OKAPI.
$cacheid2waypoints = Db::select_group_by("cache_id", "\n select\n cache_id, stage, latitude, longitude, `desc`,\n type as internal_type_id,\n case type\n when 3 then 'Flag, Red'\n when 4 then 'Circle with X'\n when 5 then 'Parking Area'\n else 'Flag, Green'\n end as sym,\n case type\n when 1 then 'physical-stage'\n when 2 then 'virtual-stage'\n when 3 then 'final'\n when 4 then 'poi'\n when 5 then 'parking'\n else 'other'\n end as okapi_type\n from waypoints\n where\n cache_id in (" . $cache_codes_escaped_and_imploded . ")\n and status = 1\n order by cache_id, stage, `desc`\n ");
} else {
# OCDE uses 'coordinates' table (with type=1) to store additional waypoints
# and defines waypoint types in 'coordinates_type' table.
# All additional waypoints are public.
$cacheid2waypoints = Db::select_group_by("cache_id", "\n select\n cache_id,\n false as stage,\n latitude, longitude,\n description as `desc`,\n subtype as internal_type_id,\n case subtype\n when 1 then 'Parking Area'\n when 3 then 'Flag, Blue'\n when 4 then 'Circle with X'\n when 5 then 'Diamond, Green'\n else 'Flag, Green'\n end as sym,\n case subtype\n when 1 then 'parking'\n when 2 then 'stage'\n when 3 then 'path'\n when 4 then 'final'\n when 5 then 'poi'\n else 'other'\n end as okapi_type\n from coordinates\n where\n type = 1\n and cache_id in (" . $cache_codes_escaped_and_imploded . ")\n order by cache_id, id\n ");
}
foreach ($cacheid2waypoints as $cache_id => $waypoints) {
$cache_code = $cacheid2wptcode[$cache_id];
$wpt_format = $cache_code . "-%0" . strlen(count($waypoints)) . "d";
$index = 0;
foreach ($waypoints as $row) {
if (!isset($internal_wpt_type_id2names[$row['internal_type_id']])) {
# Sanity check. Waypoints of undefined type won't be accessible via OKAPI.
# See issue 219.
continue;
}
$index++;
$results[$cache_code]['alt_wpts'][] = array('name' => sprintf($wpt_format, $index), 'location' => round($row['latitude'], 6) . "|" . round($row['longitude'], 6), 'type' => $row['okapi_type'], 'type_name' => Okapi::pick_best_language($internal_wpt_type_id2names[$row['internal_type_id']], $langpref), 'sym' => $row['sym'], 'description' => ($row['stage'] ? _("Stage") . " " . $row['stage'] . ": " : "") . $row['desc']);
}
}
# Issue #298 - User coordinates implemented in oc.pl
# Issue #305 - User coordinates implemented in oc.de
if ($request->token != null) {
# Query DB for user provided coordinates
if (Settings::get('OC_BRANCH') == 'oc.pl') {
$cacheid2user_coords = Db::select_group_by('cache_id', "\n select\n cache_id, longitude, latitude\n from cache_mod_cords\n where\n cache_id in ({$cache_codes_escaped_and_imploded})\n and user_id = '" . mysql_real_escape_string($request->token->user_id) . "'\n ");
} else {
# oc.de
$cacheid2user_coords = Db::select_group_by('cache_id', "\n select\n cache_id, longitude, latitude\n from coordinates\n where\n cache_id in ({$cache_codes_escaped_and_imploded})\n and user_id = '" . mysql_real_escape_string($request->token->user_id) . "'\n and type = 2\n and longitude != 0\n and latitude != 0\n ");
}
foreach ($cacheid2user_coords as $cache_id => $waypoints) {
$cache_code = $cacheid2wptcode[$cache_id];