]> git.mxchange.org Git - friendica.git/blobdiff - include/dbm.php
Merge pull request #2686 from rabuzarus/2107-contact_edit
[friendica.git] / include / dbm.php
index f68987c2356d23a016bfdc4a0546c0f1d25d9f37..fdd9f40e762a1b1443de691390f3cca572703634 100644 (file)
@@ -1,18 +1,31 @@
 <?php
+/**
+ * @brief This class contain functions for the database management
+ *
+ */
 class dbm {
+       /**
+        * @brief Return a list of database processes
+        *
+        * @return array
+        *      'list' => List of processes, separated in their different states
+        *      'amount' => Number of concurrent database processes
+        */
        public static function processlist() {
                $r = q("SHOW PROCESSLIST");
                $s = array();
 
+               $processes = 0;
                $states = array();
                foreach ($r AS $process) {
                        $state = trim($process["State"]);
-                       if (!in_array($state, array("", "init", "statistics")))
+
+                       // Filter out all idle processes
+                       if (!in_array($state, array("", "init", "statistics"))) {
                                ++$states[$state];
+                               ++$processes;
+                       }
                }
-               // query end
-               // Sending data
-               // updating
 
                $statelist = "";
                foreach ($states AS $state => $usage) {
@@ -20,7 +33,17 @@ class dbm {
                                $statelist .= ", ";
                        $statelist .= $state.": ".$usage;
                }
-               return($statelist);
+               return(array("list" => $statelist, "amount" => $processes));
+       }
+
+       /**
+        * Checks if $array is a filled array with at least one entry.
+        *
+        * @param       $array  mixed   A filled array with at least one entry
+        * @return      Whether $array is a filled array
+        */
+       public static function is_result($array) {
+               return (is_array($array) && count($array) > 0);
        }
 }
 ?>