Example #1
0
 /**
  *	Instantiate class
  *	@param $dsn string
  *	@param $user string
  *	@param $pw string
  *	@param $options array
  **/
 function __construct($dsn, $user = NULL, $pw = NULL, array $options = NULL)
 {
     $fw = \Base::instance();
     $this->uuid = $fw->hash($this->dsn = $dsn);
     if (preg_match('/^.+?(?:dbname|database)=(.+?)(?=;|$)/i', $dsn, $parts)) {
         $this->dbname = $parts[1];
     }
     if (!$options) {
         $options = array();
     }
     if (isset($parts[0]) && strstr($parts[0], ':', TRUE) == 'mysql') {
         $options += array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . strtolower(str_replace('-', '', $fw->get('ENCODING'))) . ';');
     }
     parent::__construct($dsn, $user, $pw, $options);
     $this->engine = parent::getattribute(parent::ATTR_DRIVER_NAME);
 }