Version 0.9.5 beta - bugfix for the PDO adapter in MySQL, now working correctly with all encodings.
This commit is contained in:
@@ -21,6 +21,7 @@ class Mysql implements IMysql
|
|||||||
protected $_hostname = self::PLACE_HOSTNAME;
|
protected $_hostname = self::PLACE_HOSTNAME;
|
||||||
protected $_dbname = self::PLACE_DATABASE;
|
protected $_dbname = self::PLACE_DATABASE;
|
||||||
protected $_port = self::PLACE_PORT;
|
protected $_port = self::PLACE_PORT;
|
||||||
|
protected $_encoding = self::PLACE_ENCODING;
|
||||||
|
|
||||||
protected $_conn = self::PLACE_CONNECTION;
|
protected $_conn = self::PLACE_CONNECTION;
|
||||||
|
|
||||||
@@ -42,15 +43,12 @@ class Mysql implements IMysql
|
|||||||
$this->_setDiver($settings[self::PLACE_DRIVER]);
|
$this->_setDiver($settings[self::PLACE_DRIVER]);
|
||||||
$this->_setHostname($settings[self::PLACE_HOSTNAME]);
|
$this->_setHostname($settings[self::PLACE_HOSTNAME]);
|
||||||
$this->_setPort($settings[self::PLACE_PORT]);
|
$this->_setPort($settings[self::PLACE_PORT]);
|
||||||
|
$this->_setEncoding($settings[self::PLACE_ENCODING]);
|
||||||
$this->_setDsn();
|
$this->_setDsn();
|
||||||
$this->_setConn();
|
$this->_setConn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param false $section
|
|
||||||
* @return Mysql
|
|
||||||
*/
|
|
||||||
public static function getInstance( $section = false ): Mysql
|
public static function getInstance( $section = false ): Mysql
|
||||||
{
|
{
|
||||||
$className = get_called_class();
|
$className = get_called_class();
|
||||||
@@ -58,6 +56,22 @@ class Mysql implements IMysql
|
|||||||
return self::$_instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getEncoding(): string
|
||||||
|
{
|
||||||
|
return $this->_encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $encoding
|
||||||
|
*/
|
||||||
|
private function _setEncoding(string $encoding): void
|
||||||
|
{
|
||||||
|
$this->_encoding = strtolower($encoding);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -162,12 +176,13 @@ class Mysql implements IMysql
|
|||||||
return $this->_conn;
|
return $this->_conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $conn
|
* @desc set a new database connection
|
||||||
*/
|
*/
|
||||||
private function _setConn( )
|
private function _setConn( )
|
||||||
{
|
{
|
||||||
$this->_conn = new \PDO($this->getDsn(), $this->getUsername(), $this->getPassword());
|
$this->_conn = new \PDO($this->getDsn(), $this->getUsername(), $this->getPassword());
|
||||||
|
$this->_conn->query("SET NAMES '".$this->getEncoding()."'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user