-
Joel Kuder authored
rename top and topframe files
14f2a778
sql.class.php 1.15 KiB
<?php
/*
* Example Query
*
* $q = sql::$db->prepare("SELECT id, name FROM `users` WHERE `username` = ?");
* $q -> execute( array( $_POST['username'] ) ); //Yes, you can use the raw userinput without sanitizing!
* while( $r = $q->fetch( 2 ) ){
* echo $r['id'];
* }
*
*/
class sql
{
public static $db = false;
private static $config;
private function connect() {
self::$config = parse_ini_file('lib/config.ini', true);
$dsn = self::$config['db_type'] . ":host=" . self::$config['db_host'] . ";dbname=" . self::$config['db_base'];
try {
self::$db = new PDO($dsn, self::$config['db_user'], self::$config['db_pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die('Verbindung zum Mysql Server fehlgeschlagen! <br>Tipp: <a href="http://www.vms-tutorial.de/wiki//Lib/Functions">http://www.vms-tutorial.de/wiki//Lib/Functions</a>');
}
}
public static function init(){
self::connect();
return;
}
}
// Init the SQL Class
sql::init();