diff options
Diffstat (limited to 'Database/meth_dbsearch.php')
| -rw-r--r-- | Database/meth_dbsearch.php | 104 |
1 files changed, 77 insertions, 27 deletions
diff --git a/Database/meth_dbsearch.php b/Database/meth_dbsearch.php index 5104d15..7557583 100644 --- a/Database/meth_dbsearch.php +++ b/Database/meth_dbsearch.php @@ -13,58 +13,108 @@ class DbSearch extends DbMain { // Récupération des infos d'un compte par son id final public function get_user_account_by_id($id) { - $reqSearchUser = "SELECT userId, email, inscriptionDate, isClient, isPro, isAdmin - FROM ".$this->tableUserAccount." WHERE userId = ?"; + $reqSearchUser = " + SELECT + userId, email, inscriptionDate, userStatus + FROM + ".$this->tableUserAccount." + WHERE + userId = ?"; $result = $this->exec_cmd($reqSearchUser, array($id))->fetch(PDO::FETCH_ASSOC); return $result; } // Récupération des infos d'un utilisateur par son id final public function get_user_info_by_id($id) { - $reqGetUserInfo = "SELECT lastname, firstname, job, degree, - capability, description, phoneNumber, - adress, zipCode, city - FROM ".$this->tableUserInfo." WHERE userId = ?"; + $reqGetUserInfo = " + SELECT + userId, lastname, firstname, degree, + capability, description, phoneNumber, + adress, zipCode, city + FROM + ".$this->tableUserInfo." + WHERE + userId = ?"; $result = $this->exec_cmd($reqGetUserInfo, array($id))->fetchAll(PDO::FETCH_ASSOC); return $result; } // Récupération des infos d'un pro par son nom final public function get_pro_info_by_lastname($research) { - $reqSearchConsultant = "SELECT ".$this->tableUserInfo.".userId, lastname, firstname, job, capability - FROM ".$this->tableUserInfo." - INNER JOIN ".$this->tableUserAccount." - ON ".$this->tableUserInfo.".userId = ".$this->tableUserAccount.".userId - WHERE isPro = '1' AND lastname LIKE CONCAT('%', ?, '%')"; + $reqSearchConsultant = " + SELECT + ".$this->tableUserInfo.".userId, + lastname, firstname, capability + FROM + ".$this->tableUserInfo." + INNER JOIN + ".$this->tableUserAccount." + ON + ".$this->tableUserInfo.".userId = ".$this->tableUserAccount.".userId + WHERE + userStatus = '1' + AND + lastname LIKE CONCAT('%', ?, '%')"; $result = $this->exec_cmd($reqSearchConsultant, array($research))->fetchAll(PDO::FETCH_ASSOC); return $result; } // Récupération des emploies associés à un pro - final public function get_pro_job_category($id) { - $reqGetAll = "SELECT jobCategoryId FROM ".$this->tableUserJob." WHERE userId = ?"; - $result = $this->exec_cmd($reqGetAll, array($id))->fetchAll(PDO::FETCH_NUM); - $proJobs = []; - for ($i = 0; $i < count($result); $i++) { - array_push($proJobs, $result[$i][0]); - } - return $proJobs; + final public function get_pro_job_category($proId) { + $reqGetAll = " + SELECT + ".$this->tableUserJob.".jobCategoryId, + jobCategoryNameEn, jobCategoryNameFr + FROM + ".$this->tableUserJob." + INNER JOIN + ".$this->tableJobCategory." + ON + ".$this->tableUserJob.".jobCategoryId = ".$this->tableJobCategory.".jobCategoryId + WHERE + userId = ?"; + $result = $this->exec_cmd($reqGetAll, array($proId))->fetchAll(PDO::FETCH_ASSOC); + return $result; } // Récupération des notes d'un consultant par son nom - final public function get_pro_note_by_lastname($name) { - $reqCountMission = "SELECT note FROM ".$this->tableMission." - INNER JOIN ".$this->tableUserInfo." - ON ".$this->tableMission.".proId = ".$this->tableUserInfo.".userId - WHERE lastname = ?"; - $result = $this->exec_cmd($reqCountMission, array($name))->fetchAll(PDO::FETCH_ASSOC); + final public function get_pro_note_by_id($proId) { + $reqCountMission = " + SELECT + note + FROM + ".$this->tableMission." + INNER JOIN + ".$this->tableUserInfo." + ON + ".$this->tableMission.".proId = ".$this->tableUserInfo.".userId + WHERE + proId = ?"; + $result = $this->exec_cmd($reqCountMission, array($proId))->fetchAll(PDO::FETCH_NUM); return $result; } // Récupérer toutes les infos de la table jobCategory final public function get_job_category_all() { - $reqGetAll = "SELECT * FROM ".$this->tableJobCategory; - $result = $this->exec_cmd($reqGetAll, array())->fetchAll(PDO::FETCH_ASSOC); + $reqGetAllJobs = " + SELECT + * + FROM + ".$this->tableJobCategory; + $result = $this->exec_cmd($reqGetAllJobs, array())->fetchAll(PDO::FETCH_ASSOC); + return $result; + } + + // Récupérer toutes les infos de la table jobCategory + final public function get_job_category_by_id($jobId) { + $reqGetJobinfo = " + SELECT + * + FROM + ".$this->tableJobCategory." + WHERE + jobCategoryId = ?"; + $result = $this->exec_cmd($reqGetJobinfo, array($jobId))->fetchAll(PDO::FETCH_ASSOC); return $result; } } |
