Exemplo n.º 1
0
<?php

// KioCMS - Kiofol Content Managment System
// includes/mysql.php
defined('KioCMS') || exit;
$cfg->system['queries'] = 0;
if (DB_PDO) {
    try {
        define('OPD_DIR', ROOT . 'system/OPD/');
        require OPD_DIR . 'opd.class.php';
        $sql = new OPD('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . (DB_PORT ? ';port=' . DB_PORT : null), DB_USER, DB_PASS);
        $sql->setCacheDirectory(ROOT . CACHE_DIR);
        //		$sql->debugConsole = true;
        //$sql = new MyPDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.(DB_PORT ? ';port='.DB_PORT : null), DB_USER, DB_PASS);
        $sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql->exec('SET NAMES utf8');
    } catch (Exception $e) {
        exit('<div style="text-align: center;"><br /><h3>' . t('Error while connecting to SQL database!') . '</h3><code>' . $e->getMessage() . '</code></div>');
        //exit('<h3>Error while connecting to SQL database!</h3><code>'.$e->getMessage().'</code><p>For more information check log file.</p>');
    }
}
function query($content)
{
    global $sql;
    return $sql->query($content);
}
/*
mysql_connect(DB_HOST, DB_USER, DB_PASS) || die(mysql_error());
mysql_select_db(DB_NAME) || die(mysql_error());

function sql_query($query)
Exemplo n.º 2
0
 public static function create($config)
 {
     if (is_string($config)) {
         $config = parse_ini_file($config);
     }
     if (!is_array($config)) {
         throw new Exception('Invalid Open Power Driver configuration: no configuration array.');
     }
     $opd = new OPD($config['dsn'], $config['user'], $config['password']);
     if (isset($config['cache'])) {
         $opd->setCacheDirectory($config['cache']);
     }
     if (isset($config['debugConsole'])) {
         $opd->debugConsole = $config['debugConsole'];
     }
     return $opd;
 }