aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/admin/sql_console_form.php
diff options
context:
space:
mode:
Diffstat (limited to 'templates/admin/sql_console_form.php')
-rw-r--r--templates/admin/sql_console_form.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/templates/admin/sql_console_form.php b/templates/admin/sql_console_form.php
new file mode 100644
index 0000000..3b27daa
--- /dev/null
+++ b/templates/admin/sql_console_form.php
@@ -0,0 +1,45 @@
+<form class="sqlQueryForm" hx-post="/fragment/admin/sql-console/query" hx-target="this" hx-swap="outerHTML"
+ hx-disabled-elt="find button">
+ <div class="row">
+ <div class="column">
+ <label for="sqlQueryInput"><?= __('admin.sqlConsole.query.label') ?></label>
+ <textarea id="sqlQueryInput" name="query" class="codeEdit"
+ autocomplete="off"><?= $_POST['query'] ?? '' ?></textarea>
+ </div>
+ <div class="column">
+ <button type="submit" class="primary"><?= __('admin.sqlConsole.query.action') ?></button>
+ </div>
+ </div>
+
+ <?php if (isset($error)) {
+ call_template('alertbox', ['variety' => 'error', 'message' => $error->getMessage()]);
+ } ?>
+
+ <?php if (isset($results)): ?>
+ <div class="row tableContainer">
+ <h3><?= __f('admin.sqlConsole.results.heading', count($results)) ?></h3>
+ <?php if (count($results) > 0): ?>
+ <div class="tableContainer">
+ <table>
+ <thead>
+ <tr>
+ <?php foreach ($results[0] as $header => $_): ?>
+ <th><?= htmlspecialchars($header) ?></th>
+ <?php endforeach; ?>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach ($results as $row): ?>
+ <tr>
+ <?php foreach ($row as $value): ?>
+ <td><?= htmlspecialchars($value); ?></td>
+ <?php endforeach; ?>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+ <?php endif; ?>
+ </div>
+ <?php endif; ?>
+</form> \ No newline at end of file