Compare commits
No commits in common. "e6b59be095f5b7e130959a49d8b68e131e3fb832" and "b6b791d53aae257cc64781de31ace7a9283643d5" have entirely different histories.
e6b59be095
...
b6b791d53a
@ -1,22 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
<?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