Bearsampp 2025.8.29
Loading...
Searching...
No Matches
class.action.debugMysql.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
17{
27 public function __construct($args)
28 {
29 global $bearsamppLang, $bearsamppBins, $bearsamppTools, $bearsamppWinbinder;
30
31 if (isset($args[0]) && !empty($args[0])) {
32 $editor = false;
33 $msgBoxError = false;
34 $caption = $bearsamppLang->getValue(Lang::DEBUG) . ' ' . $bearsamppLang->getValue(Lang::MYSQL) . ' - ';
35
36 // Determine the command and set the caption accordingly
37 if ($args[0] == BinMysql::CMD_VERSION) {
38 $caption .= $bearsamppLang->getValue(Lang::DEBUG_MYSQL_VERSION);
39 } elseif ($args[0] == BinMysql::CMD_VARIABLES) {
40 $editor = true;
41 $caption .= $bearsamppLang->getValue(Lang::DEBUG_MYSQL_VARIABLES);
42 } elseif ($args[0] == BinMysql::CMD_SYNTAX_CHECK) {
44 }
45 $caption .= ' (' . $args[0] . ')';
46
47 // Execute the MySQL command and get the output
48 $debugOutput = $bearsamppBins->getMysql()->getCmdLineOutput($args[0]);
49
50 // Handle syntax check results
51 if ($args[0] == BinMysql::CMD_SYNTAX_CHECK) {
52 $msgBoxError = !$debugOutput['syntaxOk'];
53 $debugOutput['content'] = $debugOutput['syntaxOk'] ? 'Syntax OK !' : $debugOutput['content'];
54 }
55
56 // Display the output in an editor or message box
57 if ($editor) {
58 Util::openFileContent($caption, $debugOutput['content']);
59 } else {
60 if ($msgBoxError) {
61 $bearsamppWinbinder->messageBoxError(
62 $debugOutput['content'],
63 $caption
64 );
65 } else {
66 $bearsamppWinbinder->messageBoxInfo(
67 $debugOutput['content'],
68 $caption
69 );
70 }
71 }
72 }
73 }
74}
global $bearsamppBins
global $bearsamppLang
const CMD_SYNTAX_CHECK
const CMD_VERSION
const CMD_VARIABLES
const DEBUG_MYSQL_SYNTAX_CHECK
const DEBUG
const DEBUG_MYSQL_VERSION
const MYSQL
const DEBUG_MYSQL_VARIABLES
static openFileContent($caption, $content)