Connect PDO with c9.io

workspace
php

#1

Hello,

I’m trying to connect MySql database in PDO, but I don’t know because don’t stay connected. Someone can to try help me?

<?php

/* MySql Daten */

define(‘DB_HOST’, ‘igorronchi-homecontrol-1179525’);
define(‘DB_USER’, ‘igorronchi’);
define(‘DB_PASS’, ‘’);
define(‘DB_PORT’, ‘3306’);
define(‘DB_NAME’, ‘DAI_DB’);
define(‘DB_CHARSET’, ‘utf8’);
define(‘PREFIX’, ‘pi_’);

define(‘LANGUAGE’, ‘en’);

//define(‘BASE’, ‘http://’.$_SERVER[‘HTTP_HOST’].’/’);
//define(‘SERVER_PATH’, ‘/home/www/’);
define(‘BASE’, ‘’);
define(‘SERVER_PATH’, ‘’);

function name($name)
{
$n = explode(" ", $name);
if(count($n)==0)
{
$r = $name[0].$name[1];
}else{
$r = $n[0][0].$n[1][0];
}
return strtoupper($r);
}

Database connect:

<?php class Database { private $_con; public function __construct() { return $this->con(); }
function con()

{
$this->_con = new PDO(‘mysql:host=’.DB_HOST.’; port=’.DB_PORT. ‘; dbname=’.DB_NAME, DB_USER, DB_PASS);
$this->_con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$this->_con->exec("SET CHARACTER SET ".DB_CHARSET); // return all sql requests as UTF-8
return $this->_con;
}

}