-
Re: Maintenance System
So long story short,
There was not yet a row in the database.
I wrote a check for Glee that INSERTS if there's no row yet and UPDATES when there's a row already.
-
Re: Maintenance System
Quote:
Originally Posted by
Glee
I give full credit to @
Joorren for this.
PHP Code:
function checkMaintenance()
{
global $config, $dbh;
if (isset($_POST['checkMaintenance']))
{
switch ($_POST['checkMaintenance']) {
case 'open':
default:
$siteMode = "open";
break;
case 'closed':
$siteMode = "closed";
break;
}
// Check if there's already a row
$checkRow = $dbh->prepare("SELECT * FROM cms_site");
$checkRow->execute();
// If the row already exists, update
if ($checkRow->fetch()) {
$checkMaintenance = $dbh->prepare("UPDATE cms_site SET site_closed = :siteOption");
$checkMaintenance->bindParam(':siteOption', $siteMode);
$checkMaintenance->execute();
}
// Else, insert
else {
$checkMaintenance = $dbh->prepare("INSERT INTO cms_site VALUES (:siteOption, '')");
$checkMaintenance->bindParam(':siteOption', $siteMode);
$checkMaintenance->execute();
}
if ($siteMode === 'open') {
Admin::succeed("Maintenance Mode Disabled");
}
else {
Admin::succeed("Maintenance Mode Enabled");
}
}
}
Is it working?
-
Re: Maintenance System
Quote:
Originally Posted by
neto737
Is it working?
Yes. It’s inserting into my database now. Now I’m creating class.html.php function
Sent from my iPhone using Tapatalk