function __construct($bt_db_host, $bt_db_name, $bt_db_user, $bt_db_pass, $bt_db_type = 'mysql', $bt_db_charset = 'UTF8')
 {
     $error =& singleton::get(__NAMESPACE__ . '\\error');
     switch ($bt_db_type) {
         case 'mysql':
             if (array_search('mysql', parent::getAvailableDrivers()) === FALSE) {
                 $error->create(array('type' => 'sql_type_unsupported', 'message' => 'Unable to find the PDO MySQL database driver, which is required with the current database settings.'));
             }
             try {
                 $connection = parent::__construct('mysql:host=' . $bt_db_host . ';dbname=' . $bt_db_name, $bt_db_user, $bt_db_pass, array(PDO::ATTR_PERSISTENT => false));
             } catch (\PDOException $e) {
                 $error->create(array('type' => 'sql_connect_error', 'message' => $e->getMessage()));
             }
             //set charset
             parent::exec('SET CHARACTER SET ' . $bt_db_charset);
             parent::exec('SET NAMES ' . $bt_db_charset);
             return $connection;
             break;
         default:
             $error->create(array('type' => 'sql_type_unsupported', 'message' => 'Database "' . $bt_db_type . '" is unsupported.'));
     }
 }
 private function create()
 {
     $error =& singleton::get(__NAMESPACE__ . '\\error');
     $query = "INSERT INTO {$this->tb}\n\t\t(session_id, session_start, session_start_utc, session_expire, session_expire_utc, ip_address, `site_id`)\n\t\tVALUES\n\t\t(:session_id, :session_start, :session_start_utc, :session_expire, :session_expire_utc, :ip_address, :site_id)\n\t\t";
     $ip_address = ip_address();
     $session_id = session_id();
     $datetime = datetime();
     $datetime_utc = datetime_utc();
     $datetime_expire = datetime($this->life_time);
     $datetime_expire_utc = datetime_utc($this->life_time);
     $stmt = $this->db->prepare($query);
     $stmt->bindParam(':session_id', $session_id);
     $stmt->bindParam(':session_start', $datetime);
     $stmt->bindParam(':session_start_utc', $datetime_utc);
     $stmt->bindParam(':session_expire', $datetime_expire);
     $stmt->bindParam(':session_expire_utc', $datetime_expire_utc);
     $stmt->bindParam(':ip_address', $ip_address, database::PARAM_STR);
     $stmt->bindParam(':site_id', $this->site_id, database::PARAM_INT);
     try {
         $stmt->execute();
     } catch (\Exception $e) {
         $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
     }
     return true;
 }