do not require PDO if we're using mocha-dotnet

This commit is contained in:
Michael Becker 2025-01-12 23:28:39 -05:00
parent 162cbff537
commit f20fa1f393

View File

@ -26,7 +26,7 @@
catch (\Exception $ex) catch (\Exception $ex)
{ {
$pdoex = $ex; $pdoex = $ex;
echo($pdoex); die(); // echo($pdoex); die();
} }
$basepath = $_SERVER["SERVER_NAME"]; $basepath = $_SERVER["SERVER_NAME"];
@ -34,31 +34,33 @@
{ {
protected function OnPreRender(CancelEventArgs $e) protected function OnPreRender(CancelEventArgs $e)
{ {
global $pdo;
global $basepath; global $basepath;
$e->Cancel = true; $e->Cancel = true;
if ($_POST["reset"] == "1") if ($_POST["reset"] == "1")
{ {
$stmt = $pdo->prepare("DELETE FROM mocha_attributes WHERE tenant_id > 2"); global $pdo;
$stmt->execute(); if ($pdo !== null) {
$stmt = $pdo->prepare("DELETE FROM mocha_attributes WHERE tenant_id > 2");
$stmt->execute();
$stmt = $pdo->prepare("DELETE FROM mocha_relationships WHERE tenant_id > 2"); $stmt = $pdo->prepare("DELETE FROM mocha_relationships WHERE tenant_id > 2");
$stmt->execute(); $stmt->execute();
$stmt = $pdo->prepare("DELETE FROM mocha_instances WHERE tenant_id > 2"); $stmt = $pdo->prepare("DELETE FROM mocha_instances WHERE tenant_id > 2");
$stmt->execute(); $stmt->execute();
$stmt = $pdo->prepare("DELETE FROM mocha_tenant_references WHERE source_tenant_id > 2"); $stmt = $pdo->prepare("DELETE FROM mocha_tenant_references WHERE source_tenant_id > 2");
$stmt->execute(); $stmt->execute();
$stmt = $pdo->prepare("DELETE FROM mocha_tenants WHERE id > 2"); $stmt = $pdo->prepare("DELETE FROM mocha_tenants WHERE id > 2");
$stmt->execute(); $stmt->execute();
header("HTTP/1.1 302 Found"); header("HTTP/1.1 302 Found");
header("Location: /suv/suvinfo.html"); header("Location: /suv/suvinfo.html");
exit(); exit();
}
} }
$path = System::GetVirtualPath(); $path = System::GetVirtualPath();
@ -328,39 +330,40 @@ EOF
else else
{ {
global $pdo; global $pdo;
global $basepath; if ($pdo !== null) {
global $basepath;
$query = "SELECT * FROM mocha_tenants"; $query = "SELECT * FROM mocha_tenants";
$stmt = $pdo->prepare($query); $stmt = $pdo->prepare($query);
try try {
{ $result = $stmt->execute();
$result = $stmt->execute(); $rows = $stmt->fetchAll();
$rows = $stmt->fetchAll(); foreach ($rows as $values) {
foreach ($rows as $values) if ($values["is_library"] != 0) {
{ continue;
if ($values["is_library"] != 0) }
{ ?>
continue; <tr>
<td><a class="uwt-external-link" target="_blank" href="<?php echo ("https://" . $basepath . "/" . $values["tenant_name"]); ?>"><?php echo ($values["tenant_name"]); ?></a></td>
<td>Active</td>
<td>Development</td>
<td>Local</td>
<td>No Charge</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><?php echo ($values["tenant_purpose"]); ?></td>
</tr>
<?php
} }
?> } catch (\Exception $ex) {
<tr> echo ("<tr><td colspan=\"10\">" . $ex . "</td></tr>");
<td><a class="uwt-external-link" target="_blank" href="<?php echo("https://" . $basepath . "/" . $values["tenant_name"]); ?>"><?php echo ($values["tenant_name"]); ?></a></td>
<td>Active</td>
<td>Development</td>
<td>Local</td>
<td>No Charge</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><?php echo($values["tenant_purpose"]); ?></td>
</tr>
<?php
} }
} }
catch (\Exception $ex) else
{ {
echo ("<tr><td colspan=\"10\">" . $ex . "</td></tr>"); // FIXME : use mocha-dotnet
} }
} }
?> ?>