3 * @brief This class contain functions for the database management
8 * @brief Return a list of database processes
11 * 'list' => List of processes, separated in their different states
12 * 'amount' => Number of concurrent database processes
14 public static function processlist() {
15 $r = q("SHOW PROCESSLIST");
20 foreach ($r AS $process) {
21 $state = trim($process["State"]);
23 // Filter out all non blocking processes
24 if (!in_array($state, array("", "init", "statistics", "updating"))) {
31 foreach ($states AS $state => $usage) {
34 $statelist .= $state.": ".$usage;
36 return(array("list" => $statelist, "amount" => $processes));
40 * Checks if $array is a filled array with at least one entry.
42 * @param $array mixed A filled array with at least one entry
43 * @return Whether $array is a filled array
45 public static function is_result($array) {
46 // It could be a return value from an update statement
47 if (is_bool($array)) {
50 return (is_array($array) && count($array) > 0);
54 * @brief Callback function for "esc_array"
56 * @param mixed $value Array value
57 * @param string $key Array key
58 * @param boolean $add_quotation add quotation marks for string values
60 private static function esc_array_callback(&$value, $key, $add_quotation) {
62 if (!$add_quotation) {
63 if (is_bool($value)) {
64 $value = ($value ? '1' : '0');
66 $value = dbesc($value);
71 if (is_bool($value)) {
72 $value = ($value ? 'true' : 'false');
73 } elseif (is_numeric($value)) {
74 $value = (string)$value;
76 $value = "'".dbesc($value)."'";
81 * @brief Escapes a whole array
83 * @param mixed $arr Array with values to be escaped
84 * @param boolean $add_quotation add quotation marks for string values
86 public static function esc_array(&$arr, $add_quotation = false) {
87 array_walk($arr, 'self::esc_array_callback', $add_quotation);