Source for file PolarDbQuery.class.php
Documentation is available at PolarDbQuery.class.php
* Class to query / update database to get various data
* (day info, exercises, stats, ...)
* @author Jean-Philippe Brunon <jp75018@free.fr>
* @copyright 2007-2009 Jean-Philippe Brunon
* @license http://www.opensource.org/licenses/gpl-license.php GPL
* @version $Id: PolarDbQuery.class.php 68 2009-03-28 22:57:30Z jp75018 $
* Class to query / update database to get various data
* (day info, exercises, stats, ...)
* Get user information data
* @param integer $user_id User ID
* @return array User information (associative array with plw_user
$request =
sprintf("SELECT * FROM plw_user WHERE id = %d", $user_id);
* Login user, get user information data
* User status must be 'active'.
* Also set last visit timestamp and use user language.
* @param string $email Email of user
* @param string $password Password of user
* @return array User fields on success, else null
$email_cookie =
false, $password_cookie =
false)
$request =
sprintf("SELECT * FROM plw_user WHERE status = 'active' AND LOWER(email) = '%s' AND password = MD5('%s')",
// Update last visit timestamp (do not update last mod date)
$request =
sprintf("UPDATE plw_user SET mod_date = mod_date, visit_date = NOW() WHERE id = %d",
// Use user language (only if a session)
setcookie('lang', $info['language'], $cur_time +
365 *
86400);
setcookie('email', $email, $cur_time +
365 *
86400);
setcookie('password', $password, $cur_time +
365 *
86400);
setcookie('password', '', $cur_time -
1000000);
// Unset email / password cookies
setcookie('password', '', $cur_time -
1000000);
* @param integer $user_id User ID
* @param string $old_password Old (current) user password
* @param string $new_password New user password
* @return boolean true on success, else false
$request =
sprintf("UPDATE plw_user SET password = MD5('%s') WHERE id = %d AND password = MD5('%s')",
$new_password, $user_id, $old_password);
* Create a new user (with inactive status)
* @param array $info Associative array of user fields :
* - 'nickname' : User nickname
* - 'email' : User email address
* - 'password' : User password
* - 'publish' : Publish status
* @param integer &$user_id ID of user created
* @param string &$activ_code Activation code (32 chars MD5 generated)
* @return boolean true on success, else false
$activ_code =
md5(time() .
'/' .
$email);
$request =
sprintf("INSERT INTO plw_user(nickname, email, cre_date, mod_date, activ_code, password, publish, language) VALUES('%s', '%s', NOW(), NOW(), '%s', MD5('%s'), '%s', '%s')",
$info['nickname'], $info['email'], $activ_code, $info['password'],
$info['publish'], $GLOBALS['lang']);
* @param integer $user_id ID of user to activate
* @param string $activ_code Activation code (32 chars)
* @return boolean true on success, else false
$request =
sprintf("UPDATE plw_user SET status = 'active', activ_code = NULL WHERE id = %d AND status = 'inactive' AND activ_code = '%s'",
// Add default preferences
array('mailing_lists' =>
'newsletter'));
* @param integer $user_id User ID
* @param array $info Associative array of user fields :
* - 'nickname' : User nickname
* - 'publish' : Publish status
* - 'language' : Language
* - 'unit' : Unit (metric or us)
* - 'birthdate' : Birthdate dd/mm/yy[yy] (sep /,-,., ' ')
* - 'height' : Height in cm (decimal sep is . or ,)
* - 'weight' : Weight in kg (decimal sep is . or ,)
* - 'rest_hr' : Rest HR (bpm)
* - 'max_hr' : Max HR (bpm)
* - 'vo2max' : VO2max in ml/kg/min (decimal sep is . or ,)
* - 'vma' : MAS in km/h (decimal sep is . or ,)
* @return boolean true on success, else false
if (preg_match('/^([0-9]{1,2})[\/\-\. ]([0-9]{1,2})[\/\-\. ]((19|20)?[0-9]{2})$/',
$info['birthdate'], $matches))
sprintf("%04d-%02d-%02d", $year, $matches[2], $matches[1]);
{ $info['birthdate'] =
null; }
$info['height'] =
strtr($info['height'], ',', '.');
$info['weight'] =
strtr($info['weight'], ',', '.');
$info['vo2max'] =
strtr($info['vo2max'], ',', '.');
$info['vma'] =
strtr($info['vma'], ',', '.');
$request =
sprintf("UPDATE plw_user SET nickname = '%s', publish = '%s', language = '%s', unit = '%s', gender = %s, birthdate = %s, height = %s, weight = %s, rest_hr = %s, max_hr = %s, vo2max = %s, vma = %s WHERE id = %d",
$info['nickname'], $info['publish'], $info['language'], $info['unit'],
$info['gender'] ?
'\'' .
$info['gender'] .
'\'' :
'null',
$info['birthdate'] ?
'\'' .
$info['birthdate'] .
'\'' :
'null',
$info['height'] ?
round($info['height'] *
10, 2) :
'null',
$info['weight'] ?
round($info['weight'] *
10, 2) :
'null',
$info['rest_hr'] ?
round($info['rest_hr']) :
'null',
$info['max_hr'] ?
round($info['max_hr']) :
'null',
$info['vo2max'] ?
round($info['vo2max'] *
10, 2) :
'null',
$info['vma'] ?
round($info['vma'] *
10, 2) :
'null',
// Use new language (only if a session)
* Get read rights on one user booknote for another user (or anonymous reader)
* @todo Return day info display flag
* @todo Add groups rights
* @param integer $publish_user_id ID of user owner of booknote
* @param integer $logged_user_id ID uf user logged in (null if anonymous)
* @return string Read rights, one of :
* - null : <publish_user_id> does not exist
* - 'private' : No read rights
* - 'public' : Read rights
* - 'public-but-desc' : Read rights except descriptions
* @param string &$nickname Nickname of <publish_user_id> user
if ($publish_user_id ==
$logged_user_id)
// All rights for user on itself
if (isset
($_SESSION['user_nickname']))
{ $nickname =
$_SESSION['user_nickname']; }
$request =
sprintf("SELECT publish, nickname FROM plw_user WHERE id = %d",
$rights =
$info['publish'];
$nickname =
$info['nickname'];
* @param integer $user_id User ID
* @return array User preferences : Associative array of preferences :
* - 'mailing_lists' : List of mailing lists
* - 'display_width' : Browser width in pixels
* - 'display_day_info' : Flag to display day info or not
* - 'home_exes_sums' : To display exes stats in home page
$request =
sprintf("SELECT name, value FROM plw_user_preference WHERE user_id = %d",
{ $prefs[$row['name']] =
$row['value']; }
* Insert preference if not exist, delete if value is '', else update value.
* @param integer $user_id User ID
* @param array User preferences : Associative array of preferences
* (see get_user_preferences)
* @return boolean true on success, else false
// 1. Get null and not null preferences
while (list
($name, $value) =
each($prefs))
{ $ins_prefs[$name] =
$value; }
// 2. Delete preferences with null value
$request =
sprintf("DELETE FROM plw_user_preference WHERE user_id = %d AND name IN ('%s')",
$user_id, implode('\',\'', $del_prefs));
// 3. Insert / update other preferences
while (list
($name, $value) =
each($ins_prefs))
$request =
sprintf("INSERT INTO plw_user_preference(user_id, name, value) VALUES (%d, '%s', '%s') ON DUPLICATE KEY UPDATE value = '%s'",
* Get day information data for a user
* @param integer $user_id User ID
* @param string $day Day (format : YYYY-MM-DD)
* @return array Day information (associative array with plw_day_info
$request =
sprintf("SELECT * FROM plw_day_info WHERE user_id = %d AND day = '%s'",
* Get exercise information
* @param integer $exe_id Exercise ID
* @return array Exercise information (associative array with
* plw_exercise SQL table structure)
$request =
sprintf("SELECT * FROM plw_exercise WHERE id = %d", $exe_id);
* Get exercises summary + sum / avg / max by sport within a period
* Used to compute weekly statistics for instance.
* Consider exercises in reports only.
* @param integer $user_id User ID
* @param string $min_day First day in period (format : YYYY-MM-DD)
* @param string $max_day Last day in period (format : YYYY-MM-DD)
* If null, then period ends at current date.
* @param boolean $detail true to get exercises summary, else false
* @return array Indexed by sport ID. For each sport :
* - 'nb' : Number of exercises
* - 'exe' : Array of exercises
* - 'elapsed' : Total duration in seconds * 10
* - 'real_distance' : Total real distance in meters
* - 'running_index' : Average Polar running index
* - 'max_hr' : Maximum heart rate in bpm
* - 'max_speed' : Maximum speed rate in km/h * 10
* - 'avg_cadence' : Average cadence in cycles / minute
* - 'max_cadence' : Maximum cadence in cycles / minute
* - 'ascend' : Total ascend in meters
* - 'energy' : Total energy -Polar- in Kcal
* - 'physio_energy' : Total physio energy -f(HR)- in Kcal
* - 'beat_sum' : Total number of heart beats
* For each exercise in 'exe' (if $detail = true) :
* - 'day' : Day of exercise (format : YYYY-MM-DD)
* - 'rank' : Rank of exercise in day
* - 'start_time' : Start time (format : HH:MM:SS)
* - 'elapsed' : Total duration in seconds * 10
* - 'real_distance' : Total real distance in meters
* - 'running_index' : Average Polar running index
* - 'max_hr' : Maximum heart rate in bpm
* - 'max_speed' : Maximum speed rate in km/h * 10
* - 'avg_cadence' : Average cadence in cycles / minute
* - 'max_cadence' : Maximum cadence in cycles / minute
* - 'ascend' : Total ascend in meters
* - 'energy' : Total energy -Polar- in Kcal
* - 'physio_energy' : Total physio energy -f(HR)- in Kcal
* - 'beat_sum' : Total number of heart beats
* - 'exercise_type' : exe type in ('training','contest')
// 1. Get sum / avg / max by sport
$request =
sprintf("SELECT sport_id, COUNT(*) AS nb, SUM(elapsed) AS elapsed, SUM(real_distance) AS real_distance, SUM(running_index*elapsed)/SUM(elapsed*running_index/running_index) AS running_index, MAX(max_hr) AS max_hr, MAX(max_speed) AS max_speed, SUM(avg_cadence*elapsed)/SUM(elapsed*avg_cadence/avg_cadence) AS avg_cadence, MAX(max_cadence) AS max_cadence, SUM(ascend) AS ascend, SUM(energy) AS energy, SUM(physio_energy) AS physio_energy, SUM(beat_sum) AS beat_sum FROM plw_exercise WHERE user_id = %d AND day >= '%s' AND day <= '%s' AND status = 'online' AND in_reports = 'all' GROUP BY sport_id ORDER BY sport_id",
$user_id, $min_day, $max_day ?
$max_day :
'2099-12-31');
$exes[$row['sport_id']] =
$row;
unset
($exes[$row['sport_id']]['sport_id']);
// 2. Get exercises summary
$request =
sprintf("SELECT sport_id, day, rank, start_time, elapsed, real_distance, running_index, max_hr, max_speed, avg_cadence, max_cadence, ascend, energy, physio_energy, beat_sum, exercise_type FROM plw_exercise WHERE user_id = %d AND day >= '%s' AND day <= '%s' AND status = 'online' AND in_reports = 'all' ORDER BY sport_id, day, rank",
$user_id, $min_day, $max_day);
if ($row['sport_id'] !=
$prev_sport_id)
$prev_sport_id =
$row['sport_id'];
$exes[$row['sport_id']]['exe'][$i] =
$row;
unset
($exes[$row['sport_id']]['exe'][$i]['sport_id']);
* Get all laps in an exercise
* @param integer $exe_id Exercise ID
* @param string $lap_type Lap type in
* ('polar','distance','altitude','interval').
* If null, all types are returned.
* @return array Array of laps indexed by lap number from 1.
* Each lap is an associative array with plw_lap
* SQL table structure. If $lap_type is null, associative
{ $where =
sprintf("AND lap_type = '%s'", $lap_type); }
$request =
sprintf("SELECT * FROM plw_lap WHERE exercise_id = %d %s ORDER BY lap_type, rank",
$laps[$row['lap_type']][$row['rank']] =
$row;
unset
($laps[$row['lap_type']][$row['rank']]['exercise_id']);
unset
($laps[$row['lap_type']][$row['rank']]['lap_type']);
unset
($laps[$row['lap_type']][$row['rank']]['rank']);
{ $laps =
$laps[$lap_type]; }
* Get interval training elements in an exercise
* @param integer $exe_id Exercise ID
* @return array Array of interval training elements indexed from 0. Each
* element is an associative array with plw_int_training
$request =
sprintf("SELECT * FROM plw_int_training WHERE exercise_id = %d ORDER BY rank",
$elements[$row['rank']] =
$row;
unset
($elements[$row['rank']]['exercise_id']);
unset
($elements[$row['rank']]['rank']);
* Get statistics for an exercise
* Statistics are for heart rate, speed, cadence, and stride length depending
* on s_mode while recording.
* @param integer $exe_id Exercise ID
* @return array Array of statistics indexed by type in
* ('hr','speed','cadence','stride').
* For each type, statistics is an array of
* <value> => <nb of occurences in exercise>.
* <value> is bpm for 'hr', km/h * 10 for 'speed',
* cycles / minute for 'cadence', cm for 'stride'.
$request =
sprintf("SELECT * FROM plw_stat WHERE exercise_id = %d ORDER BY data_type, value",
{ $stats[$row['data_type']][$row['value']] =
$row['nb']; }
* Get statistics for all exercises within a period
* Used to compute weekly statistics for instance.
* Consider exercises in reports only.
* Statistics are for heart rate, speed, cadence, and stride length depending
* on s_mode while recording.
* @param integer $user_id User ID
* @param string $min_day First day in period (format : YYYY-MM-DD)
* @param string $max_day Last day in period (format : YYYY-MM-DD)
* @return array Array of statistics as in get_exercise_stats().
$request =
sprintf("SELECT data_type, value, SUM(nb) AS nb FROM plw_stat s, plw_exercise e WHERE e.id = s.exercise_id AND e.user_id = %d AND e.status='online' AND e.in_reports = 'all' AND e.day >= '%s' AND e.day <= '%s' GROUP BY data_type, value ORDER BY data_type, value",
$user_id, $min_day, $max_day);
{ $stats[$row['data_type']][$row['value']] =
$row['nb']; }
* Get last active and public members
* Last means most recent members (registration date). Members are sorted
* from most recent to less recent.
* @param array $params Associative array of parameters :
* - 'max_mbr' : Maximum number of members to return
* - 'max_age' : Only members newer than <max_age> days
* - 'min_exe' : Only public members with at least
* <min_exe> public exercises are considered.
* @return array Array of members indexed from 0. Each member is an
* - 'nickname' : User nickname
* - 'gender' : User gender in ('male','female')
* - 'birthdate' : User birthdate (YYYY-MM-DD)
* - 'reg_date' : registration date (YYYY-MM-DD)
* - 'exe_nb' : Number of online exercises
$max_mbr =
$params['max_mbr'] ?
$params['max_mbr'] :
100;
$max_age =
$params['max_age'] ?
$params['max_age'] :
92;
$min_exe = isset
($params['min_exe']) ?
$params['min_exe'] :
1;
$request =
sprintf("SELECT u.id AS user_id, u.nickname AS nickname, u.gender AS gender, u.birthdate AS birthdate, u.cre_date AS reg_date, COUNT(e.id) AS exe_nb FROM plw_user u, plw_exercise e WHERE u.id = e.user_id AND u.status = 'active' AND u.publish != 'private' AND e.status = 'online' AND DATEDIFF(NOW(),u.cre_date) <= %d GROUP BY u.id HAVING exe_nb >= %d ORDER BY reg_date DESC, user_id DESC LIMIT %d",
$max_age, $min_exe, $max_mbr);
// 1. Get <max_mbr> most recent active and public members
$request =
sprintf("SELECT id AS user_id, nickname, gender, birthdate, cre_date AS reg_date FROM plw_user WHERE status = 'active' AND publish != 'private' AND DATEDIFF(NOW(),cre_date) <= %d ORDER BY reg_date DESC LIMIT %d",
$users[$row['user_id']] =
$row;
// 2. Get number of exercises for those members and complete user array
$request =
sprintf("SELECT user_id, COUNT(*) AS exe_nb FROM plw_exercise WHERE status = 'online' AND user_id IN (%s) GROUP BY user_id",
{ $users[$row['user_id']]['exe_nb'] =
$row['exe_nb']; }
// 3. Build 0 .. N indexed array
while (list
($user_id, $user) =
each($users))
* Get last exercises of all public (and active) users.
* Last means most recent exercise date / time. Exercises are sorted from most
* Consider all online exercises having a matching sport ID (even unknown).
* @param array $params Associative array of parameters :
* - 'max_exe' : Maximum number of exercises to return
* - 'max_age' : Only exercises newer than <max_age> days
* - 'min_elapsed' : Only exercises during at least
* @return array Array of exercises indexed from 0. Each exercise is an
* - 'nickname' : User nickname
* - 'gender' : User gender in ('male','female')
* - 'birthdate' : User birthdate (YYYY-MM-DD)
* - 'weather' : Weather string
* - 'temperature' : Temperature in Celcius x 10
* - 'sport_index' : Sport index string
* - 'sport_name' : Sport name in case sport is unknown
* - 'exe_id' : Exercise ID
* - 'exe_type' : Exercise type string
* - 'day' : Exercise date (YYYY-MM-DD format)
* - 'start_time' : Exercise start time (HH:MI:SS format)
* - 'title' => Exercise title
* - 'monitor_type' => HR Monitor ID (polar_monitors.php)
* - 's_mode' => List of data measured (comma sep)
* - 'elapsed' => Exercice duration in seconds x 10
* - 'distance' => Exercice distance in meters
* - 'ascend' => Ascend in meters
$max_exe =
$params['max_exe'] ?
$params['max_exe'] :
100;
$max_age =
$params['max_age'] ?
$params['max_age'] :
31;
$min_elapsed =
$params['min_elapsed'] ?
$params['min_elapsed'] :
0;
$request =
sprintf("SELECT u.id AS user_id, u.nickname AS nickname, u.gender AS gender, u.birthdate AS birthdate, d.weather AS weather, d.temperature AS temperature, s.sport_index AS sport_index, s.name AS sport_name, e.id AS exe_id, e.exercise_type AS exe_type, e.day AS day, e.start_time AS start_time, e.title AS title, e.monitor_type AS monitor_type, e.s_mode AS s_mode, e.elapsed AS elapsed, e.real_distance AS distance, e.ascend AS ascend FROM plw_user u, plw_day_info d, plw_sport s, plw_exercise e WHERE u.id = d.user_id AND u.id = s.user_id AND u.id = e.user_id AND s.id = e.sport_id AND d.day = e.day AND u.status = 'active' AND u.publish != 'private' AND e.status = 'online' AND DATEDIFF(NOW(),d.day) <= %d AND e.elapsed >= %d ORDER BY day DESC, start_time DESC, user_id LIMIT %d",
$max_age, $min_elapsed *
600, $max_exe);
* Get global statistics about active members / online exercises
* Consider all active members.
* Consider all online exercises (even with none matching sport ID)
* @param array $params Associative array of parameters :
* - 'publish_list' : Array of publish status to filter
* ('public' => 'public' or 'public-but-desc')
* - 'by_publish' : Split by publish status if true
* @return array Associative arrays of records :
* + 'mbr' : active member count indexed by
* publish status ('all' if not splitted), 'public' and
* 'public-but-desc' are grouped as 'public'.
* Each record is an associative array :
* - 'nb' => Number of active members
* + 'exe' : Exercise count indexed by
* publish status ('all' if not splitted), 'public' and
* 'public-but-desc' are grouped as 'public'.
* Each record is an associative array :
* - 'nb' => Number of exercises
* - 'elapsed' => Sum of exercices duration in seconds x 10
* Both arrays are sorted by publish status;
if (in_array('public', $params['publish_list']))
{ array_push($params['publish_list'], 'public-but-desc'); }
implode('\',\'', $params['publish_list'])));
if ($params['by_publish'])
'IF(u.publish=\'private\', \'private\', \'public\') AS my_publish');
$request =
sprintf("SELECT %sCOUNT(*) AS nb FROM plw_user u WHERE u.status = 'active' %s%s%s",
count($group_by_col) ?
implode(', ', $group_by_col) .
', ' :
'',
count($group_by) ?
' GROUP BY ' .
implode(', ', $group_by) :
'',
count($order_by) ?
' ORDER BY ' .
implode(', ', $order_by) :
'');
$key_publish =
$row['my_publish'] ?
$row['my_publish'] :
'all';
{ unset
($row['my_publish']); }
$stats['mbr'][$key_publish] =
$row;
$request =
sprintf("SELECT %sCOUNT(*) AS nb, SUM(e.elapsed) AS elapsed FROM plw_user u, plw_exercise e WHERE u.id = e.user_id AND u.status = 'active' AND e.status = 'online'%s%s%s",
count($group_by_col) ?
implode(', ', $group_by_col) .
', ' :
'',
count($group_by) ?
' GROUP BY ' .
implode(', ', $group_by) :
'',
count($order_by) ?
' ORDER BY ' .
implode(', ', $order_by) :
'');
$key_publish =
$row['my_publish'] ?
$row['my_publish'] :
'all';
{ unset
($row['my_publish']); }
$stats['exe'][$key_publish] =
$row;
* Get global statistics about online exercises
* Consider all active members.
* Consider all online exercises having a matching sport ID (even unknown).
* @param array $params Associative array of parameters :
* - 'max_age' : Only exercises newer than <max_age> days
* - 'min_elapsed' : Only exercises during at least
* - 'publish_list' : Array of publish status to filter
* ('public' => 'public' or 'public-but-desc')
* - 'by_publish' : Split by publish status if true
* - 'sport_list' : Array of sport indexes to filter
* - 'by_sport' : Split by sport index if true
* @param integer &$sum_nb_exe Total nb of matching exercises
* @return array Associative array of records indexed by
* publish status ('all' if not splitted), 'public' and
* 'public-but-desc' are grouped as 'public'.
* then by sport index ('all' if not splitted).
* Each record is an associative array :
* - 'nb' => Number of exercises
* - 'elapsed' => Sum of exercices duration in seconds x 10
* - 'distance' => Sum of exercices distance in meters
* - 'ascend' => Sum of exercices ascend in meters
* Array is sorted by publish status, then by decreasing
* number of exercises for each sport.
$max_age =
$params['max_age'] ?
$params['max_age'] :
99999;
$min_elapsed =
$params['min_elapsed'] ?
$params['min_elapsed'] :
0;
if (in_array('public', $params['publish_list']))
{ array_push($params['publish_list'], 'public-but-desc'); }
implode('\',\'', $params['publish_list'])));
if ($params['by_publish'])
'IF(u.publish=\'private\', \'private\', \'public\') AS my_publish');
implode('\',\'', $params['sport_list'])));
array_push($group_by_col, 's.sport_index AS my_sport_index');
$request =
sprintf("SELECT %sCOUNT(*) AS nb, SUM(e.elapsed) AS elapsed, SUM(e.real_distance) AS distance, SUM(e.ascend) AS ascend FROM plw_user u, plw_sport s, plw_exercise e WHERE u.id = s.user_id AND u.id = e.user_id AND s.id = e.sport_id AND u.status = 'active' AND e.status = 'online' AND DATEDIFF(NOW(),e.day) <= %d AND e.elapsed >= %d%s%s%s",
count($group_by_col) ?
implode(', ', $group_by_col) .
', ' :
'',
$max_age, $min_elapsed *
600,
count($group_by) ?
' GROUP BY ' .
implode(', ', $group_by) :
'',
count($order_by) ?
' ORDER BY ' .
implode(', ', $order_by) :
'');
$key_publish =
$row['my_publish'] ?
$row['my_publish'] :
'all';
{ unset
($row['my_publish']); }
$key_sport =
$row['my_sport_index'] ?
$row['my_sport_index'] :
'all';
if ($row['my_sport_index'])
{ unset
($row['my_sport_index']); }
$stats[$key_publish][$key_sport] =
$row;
$sum_nb_exe +=
$row['nb'];
* Delete day info from database (by user ID and day)
* @param integer $user_id User ID
* @param string $day day of day info (format : YYYY-MM-DD)
* @return boolean true on success, else false (no day info)
mysql_query("DELETE FROM plw_day_info WHERE user_id = $user_id AND day = '$day'");
* Delete exercise and all related data from database by user ID, day, and rank
* Note : Get exercise ID, then calls delete_exercise_by_id().
* @param integer $user_id User ID
* @param string $day day of exercise (format : YYYY-MM-DD)
* @param integer $rank Rank of exercise within day
* @return boolean true on success, else false (no exercise)
$request =
sprintf("SELECT id FROM plw_exercise WHERE user_id = %d AND day = '%s' AND rank = %d",
* Delete exercise and all related data from database by exercise ID
* Note : Related data in tables :
* - plw_data : Exercise data as in HRM file (if recorded)
* - plw_stat : Exercise statistics (if recorded)
* - plw_int_training : Interval training elements (if type is int_training)
* - plw_lap : Exercise laps
* @param integer $id Exercise ID
* @return boolean true on success, else false (no exercise)
mysql_query("DELETE FROM plw_data WHERE exercise_id = $id");
mysql_query("DELETE FROM plw_stat WHERE exercise_id = $id");
mysql_query("DELETE FROM plw_int_training WHERE exercise_id = $id");
mysql_query("DELETE FROM plw_lap WHERE exercise_id = $id");
mysql_query("DELETE FROM plw_exercise WHERE id = $id");
Documentation generated on Sat, 28 Mar 2009 23:16:08 +0000 by phpDocumentor 1.4.1