Location: PHPKode > projects > Thin PHP Framework > ngduc-Thin-PHP-Framework-6f99097/app/model/base/driver/DBPdoMysql.php
<?php
/** 
 * Thin PHP Framework (TPF) 2011 http://thinphp.com
 *
 * Licensed under TPF License at http://bit.ly/TPFLicense
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2011, Thin PHP Framework Team
 * @link          http://thinphp.com
 * @package       app.model.base.driver
 * @license       TPF License http://bit.ly/TPFLicense
 */
defined('BASE') or exit('Direct script access is not allowed!');

class DBPdoMysql
{
	private $_dbh;
	
	public function __construct($dbinfo)
	{
		try {
			$connStr = 'mysql:host='.$dbinfo['host'].';dbname='.$dbinfo['dbname'];
			$this->_dbh = new PDO($connStr,
							$dbinfo['username'], $dbinfo['password'],
							array(
                                PDO::ATTR_PERSISTENT => true // to reuse PDO conn
                                ,PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
                            )
                        );
            //PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
			//$this->_dbh->exec("SET CHARACTER SET utf8"); // must be set for UTF8 => this doesn't work on BuyVM Offload MySQL, Unicode turn to "?" chars
		}
		catch(PDOException $e)
		{
			die('DBPdoMysql: '.$e->getMessage());
		}
	}
	
	public function getDBHandler() {
		return $this->_dbh;
	}
}
Return current item: Thin PHP Framework