apply suggestion
continuous-integration/drone/push Build is passing Details

pull/8/head
Override-6 1 year ago
parent f8e8e642d3
commit cccc68e3ce
Signed by untrusted user who does not match committer: maxime.batista
GPG Key ID: 8002CC4B4DD9ECA5

@ -10,7 +10,6 @@
"@types/node": "^16.18.59", "@types/node": "^16.18.59",
"@types/react": "^18.2.31", "@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14", "@types/react-dom": "^18.2.14",
"node-promises": "^0.2.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"typescript": "^5.2.2", "typescript": "^5.2.2",

@ -28,4 +28,5 @@ if ($match == null) {
exit(1); exit(1);
} }
header('Content-type: application/json');
call_user_func_array($match['target'], $match['params']); call_user_func_array($match['target'], $match['params']);

@ -8,5 +8,5 @@ CREATE TABLE FormEntries(name varchar, description varchar);
CREATE TABLE TacticInfo( CREATE TABLE TacticInfo(
id integer PRIMARY KEY AUTOINCREMENT, id integer PRIMARY KEY AUTOINCREMENT,
name varchar, name varchar,
creation_date timestamp creation_date timestamp DEFAULT CURRENT_TIMESTAMP
); );

@ -15,6 +15,10 @@ class Connexion {
$this->pdo = $pdo; $this->pdo = $pdo;
} }
public function lastInsertId() {
return $this->pdo->lastInsertId();
}
/** /**
* execute a request * execute a request
* @param string $query * @param string $query

@ -26,7 +26,7 @@ class TacticInfo implements \JsonSerializable {
return $this->name; return $this->name;
} }
public function getCreationDate(): int { public function getCreationTimestamp(): int {
return $this->creation_date; return $this->creation_date;
} }

@ -33,10 +33,13 @@ class TacticInfoGateway {
public function insert(string $name): TacticInfo { public function insert(string $name): TacticInfo {
$this->con->exec( $this->con->exec(
"INSERT INTO TacticInfo(name, creation_date) VALUES(:name, CURRENT_TIMESTAMP)", "INSERT INTO TacticInfo(name) VALUES(:name)",
[":name" => [$name, PDO::PARAM_STR]] [":name" => [$name, PDO::PARAM_STR]]
); );
$row = $this->con->fetch("SELECT id, creation_date FROM TacticInfo ORDER BY id DESC LIMIT 1", [])[0]; $row = $this->con->fetch(
"SELECT id, creation_date FROM TacticInfo WHERE :id = id",
[':id' => [$this->con->lastInsertId(), PDO::PARAM_INT]]
)[0];
return new TacticInfo(intval($row["id"]), $name, strtotime($row["creation_date"])); return new TacticInfo(intval($row["id"]), $name, strtotime($row["creation_date"]));
} }

@ -27,7 +27,7 @@ class TacticModel {
if ($failure) { if ($failure) {
return null; return null;
} }
return $this->tactics->insert($name); $this->tactics->insert($name);
} }
public function makeNewDefault(): ?TacticInfo { public function makeNewDefault(): ?TacticInfo {

@ -6,6 +6,7 @@
"dom.iterable", "dom.iterable",
"esnext" "esnext"
], ],
"types": ["vite/client"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true, "esModuleInterop": true,

Loading…
Cancel
Save