2024.8.23
Loading...
Searching...
No Matches
class.action.debugMariadb.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2024 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Author: Bear
6 * Website: https://bearsampp.com
7 * Github: https://github.com/Bearsampp
8 */
9
10/**
11 * Class ActionDebugMariadb
12 *
13 * This class handles debugging actions for MariaDB within the Bearsampp application.
14 * It processes command-line arguments to determine the type of debugging action to perform,
15 * retrieves the corresponding output from MariaDB, and displays it using the appropriate method.
16 */
18{
19 /**
20 * ActionDebugMariadb constructor.
21 *
22 * @param array $args Command-line arguments specifying the debugging action to perform.
23 *
24 * This constructor initializes the debugging process for MariaDB based on the provided arguments.
25 * It supports three types of debugging actions: version check, variables display, and syntax check.
26 * The output of the debugging action is displayed either in an editor or a message box.
27 */
28 public function __construct($args)
29 {
30 global $bearsamppLang, $bearsamppBins, $bearsamppTools, $bearsamppWinbinder;
31
32 if (isset($args[0]) && !empty($args[0])) {
33 $editor = false;
34 $msgBoxError = false;
35 $caption = $bearsamppLang->getValue(Lang::DEBUG) . ' ' . $bearsamppLang->getValue(Lang::MARIADB) . ' - ';
36
37 // Determine the type of debugging action based on the first argument
38 if ($args[0] == BinMariadb::CMD_VERSION) {
39 $caption .= $bearsamppLang->getValue(Lang::DEBUG_MARIADB_VERSION);
40 } elseif ($args[0] == BinMariadb::CMD_VARIABLES) {
41 $editor = true;
42 $caption .= $bearsamppLang->getValue(Lang::DEBUG_MARIADB_VARIABLES);
43 } elseif ($args[0] == BinMariadb::CMD_SYNTAX_CHECK) {
45 }
46 $caption .= ' (' . $args[0] . ')';
47
48 // Retrieve the command line output for the specified debugging action
49 $debugOutput = $bearsamppBins->getMariadb()->getCmdLineOutput($args[0]);
50
51 // Handle syntax check results
52 if ($args[0] == BinMariadb::CMD_SYNTAX_CHECK) {
53 $msgBoxError = !$debugOutput['syntaxOk'];
54 $debugOutput['content'] = $debugOutput['syntaxOk'] ? 'Syntax OK !' : $debugOutput['content'];
55 }
56
57 // Display the debugging output
58 if ($editor) {
59 Util::openFileContent($caption, $debugOutput['content']);
60 } else {
61 if ($msgBoxError) {
62 $bearsamppWinbinder->messageBoxError(
63 $debugOutput['content'],
64 $caption
65 );
66 } else {
67 $bearsamppWinbinder->messageBoxInfo(
68 $debugOutput['content'],
69 $caption
70 );
71 }
72 }
73 }
74 }
75}
global $bearsamppBins
global $bearsamppLang
const DEBUG_MARIADB_SYNTAX_CHECK
const MARIADB
const DEBUG_MARIADB_VERSION
const DEBUG
const DEBUG_MARIADB_VARIABLES
static openFileContent($caption, $content)