diff --git a/business/Task.php b/business/Task.php index 3dc7f69..efca4fa 100644 --- a/business/Task.php +++ b/business/Task.php @@ -6,6 +6,7 @@ private DateTime $dateDeb; private DateTime $dateFin; private string $priorite; + private string $idlist; // # id associating task to list function __construct($id, $titre, $description, $dateDeb, $dateFin, $priorite) { $this->titre = $titre; @@ -58,6 +59,15 @@ function set_priorite($priorite) { $this->priorite = $priorite; + } + // # getter et setter pour idList + function get_idList() { + return $this->idList; } + + function set_idList($idList) { + $this->idList = $idList; + } + } -?> \ No newline at end of file +?> diff --git a/dal/Connection.php b/dal/Connection.php index b4ce991..910c138 100644 --- a/dal/Connection.php +++ b/dal/Connection.php @@ -1,33 +1,32 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -} - - -/** * @param string $query - * @param array $parameters * - * @return bool Returns `true` on success, `false` otherwise -*/ - -public function executeQuery(string $query, array $parameters = []) : bool{ - $this->stmt = parent::prepare($query); - foreach ($parameters as $name => $value) { - $this->stmt->bindValue($name, $value[0], $value[1]); - } - - return $this->stmt->execute(); -} - -public function getResults() : array { - return $this->stmt->fetchall(); - -} -} + class Connection extends PDO { + + private $stmt; + + public function __construct(string $dsn, string $username, string $password) { + + parent::__construct($dsn,$username,$password); + $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + + + /** + * @param string $query + * @param array $parameters * + * @return bool Returns `true` on success, `false` otherwise + */ + public function executeQuery(string $query, array $parameters = []) : bool{ + $this->stmt = parent::prepare($query); + foreach ($parameters as $name => $value) { + $this->stmt->bindValue($name, $value[0], $value[1]); + } + + return $this->stmt->execute(); + } + + public function getResults() : array { + return $this->stmt->fetchall(); + } + } ?> diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php new file mode 100644 index 0000000..d4ce89c --- /dev/null +++ b/dal/TaskGateway.php @@ -0,0 +1,35 @@ +con=$con; + } + + // functions + // code de retour pour les fonctions i,u,d? + public function insert(Task $t){ + // insert a new task + } + + public function update(Task $t){ + // update a task + } + + public function delete(Task $t){ + // delete a task + } + + # comment ça marche ? + public function Find(array $elements):array{ + // Find a task by multiple elements + // returns the array of found tasks + } + } +?> diff --git a/dal/GatUser.php b/dal/UserGateway.php similarity index 100% rename from dal/GatUser.php rename to dal/UserGateway.php diff --git a/tests/credentials.php b/tests/credentials.php new file mode 100644 index 0000000..1db9dae --- /dev/null +++ b/tests/credentials.php @@ -0,0 +1,4 @@ + diff --git a/tests/ptest.php b/tests/ptest.php new file mode 100644 index 0000000..538daf2 --- /dev/null +++ b/tests/ptest.php @@ -0,0 +1,17 @@ +executeQuery($query,array( + ':prio'=>array($prio,PDO::PARAM_STR))); + +$results=$con->getResults(); +foreach($results as $row) + echo $row['id']; + +echo "
its all good!"; +?>