@@ -127,15 +127,9 @@ public static function getLoginCountPerDay($days)
127127 }
128128 $ stmt ->execute ();
129129 $ result = $ stmt ->get_result ();
130- while ($ row = $ result ->fetch_assoc ()) {
131- echo "[new Date( " .
132- $ row ["year " ] . ", " .
133- ($ row ["month " ] - 1 ) .", " .
134- $ row ["day " ] . "), {v: " .
135- $ row ["count " ] .
136- "}], " ;
137- }
130+ $ r = $ result ->fetch_all (MYSQLI_ASSOC );
138131 $ conn ->close ();
132+ return $ r ;
139133 }
140134
141135 public static function getLoginCountPerDayForService ($ days , $ spIdentifier )
@@ -165,15 +159,9 @@ public static function getLoginCountPerDayForService($days, $spIdentifier)
165159 }
166160 $ stmt ->execute ();
167161 $ result = $ stmt ->get_result ();
168- while ($ row = $ result ->fetch_assoc ()) {
169- echo "[new Date( " .
170- $ row ["year " ] . ", " .
171- ($ row ["month " ] - 1 ) . ", " .
172- $ row ["day " ] . "), {v: " .
173- $ row ["count " ] .
174- "}], " ;
175- }
162+ $ r = $ result ->fetch_all (MYSQLI_ASSOC );
176163 $ conn ->close ();
164+ return $ r ;
177165 }
178166
179167 public static function getLoginCountPerDayForIdp ($ days , $ idpIdentifier )
@@ -203,15 +191,9 @@ public static function getLoginCountPerDayForIdp($days, $idpIdentifier)
203191 }
204192 $ stmt ->execute ();
205193 $ result = $ stmt ->get_result ();
206- while ($ row = $ result ->fetch_assoc ()) {
207- echo "[new Date( " .
208- $ row ["year " ] . ", " .
209- ($ row ["month " ] - 1 ) . ", " .
210- $ row ["day " ] . "), {v: " .
211- $ row ["count " ] .
212- "}], " ;
213- }
194+ $ r = $ result ->fetch_all (MYSQLI_ASSOC );
214195 $ conn ->close ();
196+ return $ r ;
215197 }
216198
217199 public static function getAccessCountPerService ($ days )
@@ -223,15 +205,15 @@ public static function getAccessCountPerService($days)
223205 $ serviceProvidersMapTableName = $ databaseConnector ->getServiceProvidersMapTableName ();
224206 if ($ days == 0 ) { // 0 = all time
225207 $ stmt = $ conn ->prepare (
226- "SELECT service, IFNULL(name,service) AS spName, SUM(count) AS count " .
208+ "SELECT IFNULL(name,service) AS spName, service , SUM(count) AS count " .
227209 "FROM " . $ table_name . " " .
228210 "LEFT OUTER JOIN " . $ serviceProvidersMapTableName . " ON service = identifier " .
229211 "GROUP BY service HAVING service != '' " .
230212 "ORDER BY count DESC "
231213 );
232214 } else {
233215 $ stmt = $ conn ->prepare (
234- "SELECT year, month, day, service, IFNULL(name,service) AS spName, SUM(count) AS count " .
216+ "SELECT IFNULL(name,service) AS spName, service , SUM(count) AS count " .
235217 "FROM " . $ table_name . " " .
236218 "LEFT OUTER JOIN " . $ serviceProvidersMapTableName . " ON service = identifier " .
237219 "WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) " .
@@ -243,12 +225,9 @@ public static function getAccessCountPerService($days)
243225 }
244226 $ stmt ->execute ();
245227 $ result = $ stmt ->get_result ();
246- while ($ row = $ result ->fetch_assoc ()) {
247- echo "[' " .
248- str_replace ("' " , "\' " , $ row ["spName " ]) .
249- "', ' " . $ row ["service " ] . "', " . $ row ["count " ] . "], " ;
250- }
228+ $ r = $ result ->fetch_all (MYSQLI_NUM );
251229 $ conn ->close ();
230+ return $ r ;
252231 }
253232
254233 public static function getAccessCountForServicePerIdentityProviders ($ days , $ spIdentifier )
@@ -260,7 +239,7 @@ public static function getAccessCountForServicePerIdentityProviders($days, $spId
260239 $ identityProvidersMapTableName = $ databaseConnector ->getIdentityProvidersMapTableName ();
261240 if ($ days == 0 ) { // 0 = all time
262241 $ stmt = $ conn ->prepare (
263- "SELECT sourceIdp, service, IFNULL(name,sourceIdp) AS idpName, SUM(count) AS count " .
242+ "SELECT IFNULL(name,sourceIdp) AS idpName, SUM(count) AS count " .
264243 "FROM " . $ table_name . " " .
265244 "LEFT OUTER JOIN " . $ identityProvidersMapTableName . " ON sourceIdp = entityId " .
266245 "GROUP BY sourceIdp, service HAVING sourceIdp != '' AND service=? " .
@@ -269,7 +248,7 @@ public static function getAccessCountForServicePerIdentityProviders($days, $spId
269248 $ stmt ->bind_param ('s ' , $ spIdentifier );
270249 } else {
271250 $ stmt = $ conn ->prepare (
272- "SELECT year, month, day, sourceIdp, service, IFNULL(name,sourceIdp) AS idpName, SUM(count) AS count " .
251+ "SELECT IFNULL(name,sourceIdp) AS idpName, SUM(count) AS count " .
273252 "FROM " . $ table_name . " " .
274253 "LEFT OUTER JOIN " . $ identityProvidersMapTableName . " ON sourceIdp = entityId " .
275254 "WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) " .
@@ -281,10 +260,9 @@ public static function getAccessCountForServicePerIdentityProviders($days, $spId
281260 }
282261 $ stmt ->execute ();
283262 $ result = $ stmt ->get_result ();
284- while ($ row = $ result ->fetch_assoc ()) {
285- echo "[' " . str_replace ("' " , "\' " , $ row ["idpName " ]) . "', " . $ row ["count " ] . "], " ;
286- }
263+ $ r = $ result ->fetch_all (MYSQLI_NUM );
287264 $ conn ->close ();
265+ return $ r ;
288266 }
289267
290268 public static function getAccessCountForIdentityProviderPerServiceProviders ($ days , $ idpEntityId )
@@ -296,7 +274,7 @@ public static function getAccessCountForIdentityProviderPerServiceProviders($day
296274 $ serviceProvidersMapTableName = $ databaseConnector ->getServiceProvidersMapTableName ();
297275 if ($ days == 0 ) { // 0 = all time
298276 $ stmt = $ conn ->prepare (
299- "SELECT sourceIdp, service, IFNULL(name,service) AS spName, SUM(count) AS count " .
277+ "SELECT IFNULL(name,service) AS spName, SUM(count) AS count " .
300278 "FROM " . $ table_name . " " .
301279 "LEFT OUTER JOIN " . $ serviceProvidersMapTableName . " ON service = identifier " .
302280 "GROUP BY sourceIdp, service HAVING service != '' AND sourceIdp=? " .
@@ -305,7 +283,7 @@ public static function getAccessCountForIdentityProviderPerServiceProviders($day
305283 $ stmt ->bind_param ('s ' , $ idpEntityId );
306284 } else {
307285 $ stmt = $ conn ->prepare (
308- "SELECT year, month, day, sourceIdp, service, IFNULL(name,service) AS spName, SUM(count) AS count " .
286+ "SELECT IFNULL(name,service) AS spName, SUM(count) AS count " .
309287 "FROM " . $ table_name . " " .
310288 "LEFT OUTER JOIN " . $ serviceProvidersMapTableName . " ON service = identifier " .
311289 "WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) " .
@@ -317,10 +295,9 @@ public static function getAccessCountForIdentityProviderPerServiceProviders($day
317295 }
318296 $ stmt ->execute ();
319297 $ result = $ stmt ->get_result ();
320- while ($ row = $ result ->fetch_assoc ()) {
321- echo "[' " . str_replace ("' " , "\' " , $ row ["spName " ]) . "', " . $ row ["count " ] . "], " ;
322- }
298+ $ r = $ result ->fetch_all (MYSQLI_NUM );
323299 $ conn ->close ();
300+ return $ r ;
324301 }
325302
326303 public static function getLoginCountPerIdp ($ days )
@@ -332,15 +309,15 @@ public static function getLoginCountPerIdp($days)
332309 $ identityProvidersMapTableName = $ databaseConnector ->getIdentityProvidersMapTableName ();
333310 if ($ days == 0 ) { // 0 = all time
334311 $ stmt = $ conn ->prepare (
335- "SELECT sourceIdp, IFNULL(name,sourceIdp) AS idpName, SUM(count) AS count " .
312+ "SELECT IFNULL(name,sourceIdp) AS idpName, sourceIdp , SUM(count) AS count " .
336313 "FROM " . $ tableName . " " .
337314 "LEFT OUTER JOIN " . $ identityProvidersMapTableName . " ON sourceIdp = entityId " .
338315 "GROUP BY sourceIdp HAVING sourceIdp != '' " .
339316 "ORDER BY count DESC "
340317 );
341318 } else {
342319 $ stmt = $ conn ->prepare (
343- "SELECT year, month, day, sourceIdp, IFNULL(name,sourceIdp) AS idpName, SUM(count) AS count " .
320+ "SELECT IFNULL(name,sourceIdp) AS idpName, sourceIdp , SUM(count) AS count " .
344321 "FROM " . $ tableName . " " .
345322 "LEFT OUTER JOIN " . $ identityProvidersMapTableName . " ON sourceIdp = entityId " .
346323 "WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) " .
@@ -352,11 +329,8 @@ public static function getLoginCountPerIdp($days)
352329 }
353330 $ stmt ->execute ();
354331 $ result = $ stmt ->get_result ();
355- while ($ row = $ result ->fetch_assoc ()) {
356- echo "[' " .
357- str_replace ("' " , "\' " , $ row ["idpName " ]) .
358- "', ' " . $ row ['sourceIdp ' ] . "', " . $ row ["count " ] . "], " ;
359- }
332+ $ r = $ result ->fetch_all (MYSQLI_NUM );
360333 $ conn ->close ();
334+ return $ r ;
361335 }
362336}
0 commit comments