Example #1
0
 /**
  * @return Gio_Db_Mysql
  */
 public function __construct($instance = false)
 {
     if ($instance) {
         return $this;
     }
     $configs = Gio_Core_Config_Xml::getConfig('db');
     $this->_host = $configs->host;
     $this->_username = $configs->username;
     $this->_password = $configs->password;
     $this->_dbName = $configs->name;
     $this->_port = $configs->port;
     $this->_tablePrefix = $configs->table_prefix;
     $host = $this->_port != null ? $this->_host . ':' . $this->_port : $this->_host;
     $link = null;
     $connected = false;
     $connected = mysql_pconnect($host, $this->_username, $this->_password, $link) or die('Cannot connect to Database!');
     $this->_connected = $connected;
     $this->_link = $link;
     mysql_select_db($this->_dbName, $connected);
     mysql_query(sprintf("SET CHARACTER SET '%s'", mysql_real_escape_string($configs->encoding)));
     return self::$_instance = $this;
 }