public function startDebug($query, $cache = false, $cached = false)
 {
     self::$lastQuery = $query;
     $this->queries[$i] = array('query' => $query, 'result' => 0, 'cache' => $cache, 'cached' => $cached, 'time' => 0);
     if ($this->_debugConsole) {
         if (is_null($this->consoleCode)) {
             $this->consoleCode = file_get_contents(OPD_DIR . 'opd.debug.php');
         }
         $this->queries[$i]['time'] = microtime(true);
         /*		$dbg = debug_backtrace();
         				foreach($dbg as $items)
         				{
         					echo '<i>'.$items['file'].':'.$items['line'].'; '.$items['class'].':'.$items['function'].'</i><br/>';
         				}
         				echo '<b>Start: '.$this->queries[$i]['time'].'</b><br/>';*/
     }
 }
Example #2
0
<?php

define('OPD_DIR', '../lib/');
require OPD_DIR . 'opd.class.php';
try {
    $sql = opdClass::create('./config.php');
    echo '<h2>Iterator interface</h2>';
    // Get the categories
    $stmt = $sql->query('SELECT id, name FROM categories ORDER BY name');
    $stmt->setFetchMode(PDO::FETCH_ASSOC);
    echo '<ul>';
    foreach ($stmt as $row) {
        echo '<li>' . $row['id'] . ': ' . $row['name'] . '</li>';
    }
    echo '</ul>';
    $stmt->closeCursor();
    echo '<p>Queries executed: ' . $sql->getCounter() . '</p>';
} catch (PDOException $exception) {
    opdErrorHandler($exception);
}
<?php

define('OPD_DIR', '../lib/');
require '../lib/opd.class.php';
try {
    $pdo = new opdClass('mysql:host=localhost;dbname=test', 'root', 'root');
    $pdo->debugConsole = true;
    if ($_GET['connect'] == 1) {
        $pdo->exec('UPDATE `table` SET `field` = 1');
        echo '<p>Connected</p>';
    } else {
        echo '<p>Not connected</p>';
    }
} catch (PDOException $exception) {
    die('Exception: ' . $exception->getMessage());
}