1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
<?php
// ############################################################################
// # #
// # Description: Ensemble de méthodes pour étendre dbmain afin #
// # d'effectuer des recherches dans la bdd #
// # #
// ############################################################################
// Infos pour les "join":
// https://www.freecodecamp.org/news/sql-joins-tutorial/
// Import de dbmain
require_once(dirname( __FILE__ )."/dbmain.php");
// Extension de cette classe avec dbmain
class DbSearch extends DbMain {
// ****************************************************************************
// RECUPERATION DES INFORMATIONS RELATIVES AUX UTILISATEURS
// ****************************************************************************
// Récupération des infos d'un compte par son id
final public function get_user_account_by_userid($userId) {
$reqSearchUser = "
SELECT
userId, email, inscriptionDate, userStatus
FROM
".$this->tableUserAccount."
WHERE
userId = ?";
$result = $this->exec_cmd($reqSearchUser, array($userId))->fetch(PDO::FETCH_ASSOC);
return $result;
}
// Récupération des infos d'un utilisateur par son id
final public function get_user_info_by_userid($userId) {
$reqGetUserInfo = "
SELECT
userId, lastname, firstname, degree,
capability, description, phoneNumber,
adress, zipCode, city
FROM
".$this->tableUserInfo."
WHERE
userId = ?";
$result = $this->exec_cmd($reqGetUserInfo, array($userId))->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
// ****************************************************************************
// RECUPERATION DES INFORMATIONS RELATIVES AUX PROS
// ****************************************************************************
final public function get_all_pro_by_jobid($jobId) {
$reqSearchConsultant = "
SELECT
".$this->tableUserInfo.".userId,
lastname, firstname, capability
FROM
".$this->tableUserInfo."
INNER JOIN
".$this->tableUserJob."
ON
".$this->tableUserInfo.".userId = ".$this->tableUserJob.".userId
WHERE
jobCategoryId = ?";
$result = $this->exec_cmd($reqSearchConsultant, array($jobId))->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($lastname) {
$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($lastname))->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
// Récupération des emploies associés à un pro
final public function get_pro_job_by_proid($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_proid($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;
}
// ****************************************************************************
// RECUPERATION DES INFORMATIONS RELATIVES AUX EMPLOIS
// ****************************************************************************
// Récupérer toutes les infos de la table jobCategory
final public function get_job_all() {
$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_by_jobid($jobId) {
$reqGetJobinfo = "
SELECT
*
FROM
".$this->tableJobCategory."
WHERE
jobCategoryId = ?";
$result = $this->exec_cmd($reqGetJobinfo, array($jobId))->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
}
?>
|