]> git.mxchange.org Git - friendica.git/blob - include/dbm.php
[frio] Capitalize dropdown menu links
[friendica.git] / include / dbm.php
1 <?php
2 /**
3  * @brief This class contain functions for the database management
4  *
5  */
6 class dbm {
7         /**
8          * @brief Return a list of database processes
9          *
10          * @return array
11          *      'list' => List of processes, separated in their different states
12          *      'amount' => Number of concurrent database processes
13          */
14         public static function processlist() {
15                 $r = q("SHOW PROCESSLIST");
16                 $s = array();
17
18                 $processes = 0;
19                 $states = array();
20                 foreach ($r AS $process) {
21                         $state = trim($process["State"]);
22
23                         // Filter out all non blocking processes
24                         if (!in_array($state, array("", "init", "statistics", "updating"))) {
25                                 ++$states[$state];
26                                 ++$processes;
27                         }
28                 }
29
30                 $statelist = "";
31                 foreach ($states AS $state => $usage) {
32                         if ($statelist != "")
33                                 $statelist .= ", ";
34                         $statelist .= $state.": ".$usage;
35                 }
36                 return(array("list" => $statelist, "amount" => $processes));
37         }
38
39         /**
40          * Checks if $array is a filled array with at least one entry.
41          *
42          * @param       $array  mixed   A filled array with at least one entry
43          * @return      Whether $array is a filled array
44          */
45         public static function is_result($array) {
46                 return (is_array($array) && count($array) > 0);
47         }
48 }
49 ?>