added folder into database, added gateway/model methods
continuous-integration/drone/push Build is failing Details

folder
Maël DAIM 1 year ago
parent c596bfba71
commit e259d64387

@ -25,12 +25,23 @@ CREATE TABLE Tactic
FOREIGN KEY (owner) REFERENCES Account
);
CREATE TABLE FormEntries
CREATE TABLE TacticFolder
(
id integer PRIMARY KEY AUTOINCREMENT,
name varchar NOT NULL,
description varchar NOT NULL
owner integer NOT NULL,
tacticFolderParent integer,
FOREIGN KEY (owner) REFERENCES Account,
FOREIGN KEY (tacticFolderParent) REFERENCES TacticFolder
);
CREATE TABLE TacticFolderLink
(
idFolder integer NOT NULL,
idTactic integer NOT NULL,
FOREIGN KEY (idFolder) REFERENCES TacticFolder,
FOREIGN KEY (idTactic) REFERENCES Tactic
);
CREATE TABLE Team
(

@ -130,4 +130,29 @@ class TacticInfoGateway {
]);
return $stmnt->rowCount() == 1;
}
/**
* Return all the tactic of a specific folder
* If the folder's id is 0, we return all tactics at the root
* @param int $accountId
* @param int $folderId
* @return array
*/
public function getFolderTactic(int $accountId,int $folderId): array {
if($folderId == 0){
$query = "SELECT t.*
FROM Tactic t, TacticFolderLink tfl
WHERE t.owner = :ownerId AND t.id NOT IN (SELECT idTactic FROM TacticFolderLink)";
$args = ["ownerId" => [$accountId, PDO::PARAM_INT]];
}else {
$query = "SELECT t.*
FROM Tactic t, TacticFolderLink tfl
WHERE t.owner = :ownerId AND tfl.idTactic = :folderId";
$args = ["ownerId" => [$accountId, PDO::PARAM_INT],
"folderId" => [$folderId, PDO::PARAM_INT]];
}
return $this->con->fetch($query,$args);
}
}

@ -102,4 +102,8 @@ class TacticModel {
return null;
}
public function getFolderTactic(int $acountId,int $folderId = 0): array{
return $this->tactics->getFolderTactic($acountId,$folderId);
}
}

Loading…
Cancel
Save