Merge branch 'development' of goeranh/fitness-api into master
This commit is contained in:
commit
e6b59be095
22
html/api/Models/WorkoutType.php
Normal file
22
html/api/Models/WorkoutType.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
class WorkoutType{
|
||||||
|
public $id, $name, $description, $type, $unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WorkoutType constructor.
|
||||||
|
* @param $id
|
||||||
|
* @param $name
|
||||||
|
* @param $description
|
||||||
|
* @param $type
|
||||||
|
* @param $unit
|
||||||
|
*/
|
||||||
|
public function __construct($id, $name, $description, $type, $unit)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->name = $name;
|
||||||
|
$this->description = $description;
|
||||||
|
$this->type = $type;
|
||||||
|
$this->unit = $unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
37
html/api/exercises.php
Normal file
37
html/api/exercises.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
include "../../config.php";
|
||||||
|
include "Models/WorkoutType.php";
|
||||||
|
|
||||||
|
if (isset($_GET['token'])){
|
||||||
|
$sql = "SELECT * FROM tokens INNER JOIN users ON users.id=tokens.user WHERE token=?";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->bindParam(1, $_GET['token']);
|
||||||
|
if ($stmt->execute()){
|
||||||
|
if ($stmt->rowCount() == 1){
|
||||||
|
$userData = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$username = $userData[0]['username'];
|
||||||
|
$userID = $userData[0]['user'];
|
||||||
|
$sql = "select workout_types.id, name, description, type, unit from workout_types inner join workout_type_measurements on workout_types.measurement=workout_type_measurements.id ";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->bindParam(1, $userID);
|
||||||
|
if ($stmt->execute()){
|
||||||
|
$workoutTypes = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$returnTypes = array();
|
||||||
|
foreach ($workoutTypes as $workoutType){
|
||||||
|
$returnTypes[] = new WorkoutType($workoutType['id'], $workoutType['name'], $workoutType['description'], $workoutType['unit'], $workoutType['unit']);
|
||||||
|
}
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode($workoutTypes);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
var_dump($stmt->errorInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
//header('Content-Type: application/json');
|
||||||
|
}else{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user