Jump to content

AndrewPHP

New Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About AndrewPHP

  • Rank
    Newbie
  1. Great stuff, I think I'm slowly taking it in (I hope), so how's this... <?php class ScriptControl { private $pdo; private $ScriptName; public function __construct($pdo, $ScriptName) { $this->pdo = $pdo; $this->ScriptName = $ScriptName; } public function IsEnabled(); { $sql = "SELECT 1 FROM config WHERE config_name = ? AND config_value = 1 LIMIT 1"; $stmt = $this->pdo->prepare($sql); $stmt->execute([$this->ScriptName]); return $stmt->fetchColumn(); } public function IsRunnable(); { date_default_timezone_set("Europe/Londo
  2. Thanks for that, it looks like I should have stuck to the procedural side of things as this looks incredibly more complex. I also need to create some other functions too but unsure how they would break down by class. CheckIfEnabled - This function checks in the DB if this script is allowed to be run. CheckIfTime - This function checks in the DB if this script is allowed to be run at this current minute. CheckMessagesSent - This function checks in the DB to see how many messages have been sent already today CheckMessageLimit - This function checks in the DB to see how many messages a
  3. After writing procedural style PHP for many years I've decided to give OOP & PDO a go (and I'm hating it already). I have written a simple function which validate a flag value, and another function which is later used to get the description of that value. Am I on the right lines here and can any improvements be made? <?php // Connect to MySQL $dsn = 'mysql:dbname=dev_pof;host=127.0.0.1'; $username = 'dev'; $password = 'dev.dev'; $pdo = new PDO($dsn, $username, $password,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); // Function to validate the flag value function CheckF
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.