thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

PDO - OOP debug panel - Fully functional - Hopefully this will help someone #180

Closed dbashby closed 8 years ago

dbashby commented 8 years ago

I am not claiming that this is perfect, due to the amount of code I have for getting the debug panel value, it does work. This is still a work in progress and when I have solved the issue I will post the code. So where Alan started to write the query for getting the value I have the following in setup.php

`$id = "debug-status"; $stmt = $pdo->prepare("SELECT * FROM settings WHERE id = :id limit 1"); $stmt->bindParam(":id",$id,PDO::PARAM_STR); if($stmt->execute()){

    $rows = $stmt->fetchObject("Debug");
    $debug = $rows->get('value');
}`

I also have a classes.php which I have the following in

#Debug Panel: class Debug { public function get($debug) { if(property_exists($this, $debug)) { return $this->$debug; } return false; } }

and in index.php I have the same as Alan

<?php if($debug == 1){ include 'widgets/debug.php'; } ?>

Lastly in navigation.php in the widgets folder I have which I thin is the same as Alans code.

`<?php if($debug == 1){ ?>

<?php } ?>`

Although I am sure that this can be improved on, as currently it only gets the 1 piece of data from the settings table hopefully it will help someone if they are also in the process of trying to learn to work with PDO.

sitefs