Maintenance System

Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Joorren Joorren is offline
    Gold SubscriberRank
    May 2011 Join Date
    1,533Posts

    Re: Maintenance System

    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.







  2. #17
    C# Developer neto737 is offline
    True MemberRank
    Oct 2010 Join Date
    Environment.csLocation
    274Posts

    Re: Maintenance System

    Quote Originally Posted by Glee View Post
    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?

  3. #18
    Alpha Member Glee is offline
    Alpha MaleRank
    Jun 2009 Join Date
    Niagara Falls,Location
    2,224Posts

    Re: Maintenance System

    Quote Originally Posted by neto737 View Post
    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



Page 2 of 2 FirstFirst 12

Advertisement