[floe] r394 committed - adding UTF8 switcher

0 views
Skip to first unread message

fl...@googlecode.com

unread,
May 19, 2010, 8:56:28 AM5/19/10
to floe-c...@googlegroups.com
Revision: 394
Author: coretxt
Date: Wed May 19 05:55:56 2010
Log: adding UTF8 switcher
http://code.google.com/p/floe/source/detail?r=394

Modified:
/trunk/src/repository/store/mysql/MysqlConnection.class.php

=======================================
--- /trunk/src/repository/store/mysql/MysqlConnection.class.php Fri Apr 30
11:03:17 2010
+++ /trunk/src/repository/store/mysql/MysqlConnection.class.php Wed May 19
05:55:56 2010
@@ -14,6 +14,12 @@
require_once dirname(__FILE__) .'/../../../framework/EventLog.class.php';
require_once dirname(__FILE__) .'/../ResourceError.class.php';

+/**
+ * If a UTF8 connection is needed, this constant should be set to true.
+ * Should only be used if the database is not correctly configured for
UTF8 connections.
+ */
+if (!defined('MysqlConnection_ForceUTF8'))
define('MysqlConnection_ForceUTF8', false);
+
/**
* An active connection to a MySql database server.
*
@@ -22,7 +28,7 @@
*/
class MysqlConnection {

- private $_connection;
+ private $connection;
private $_db_host;
private $_db_name;
private $_db_user;
@@ -57,18 +63,19 @@
* @return boolean true on success
*/
function connect() {
- if (!is_resource($this->_connection)) {
- $this->_connection = @mysql_connect($this->_db_host, $this->_db_user,
$this->_db_pass);
- if (!is_resource($this->_connection)) {
+ if (!is_resource($this->connection)) {
+ $this->connection = @mysql_connect($this->_db_host, $this->_db_user,
$this->_db_pass);
+ if (!is_resource($this->connection)) {
$this->raiseError();
return false;
}
EventLog::info("Connected to [{$this->_db_host}]");
- if (!@mysql_select_db($this->_db_name, $this->_connection)) {
+ if (!@mysql_select_db($this->_db_name, $this->connection)) {
$this->raiseError();
return false;
}
EventLog::info("Selected [{$this->_db_name}]");
+ if (MysqlConnection_ForceUTF8) mysql_set_charset('utf8',
$this->connection);
}
return true;
}
@@ -86,7 +93,7 @@
*/
function execute($sql) {
$this->connect();
- $query = mysql_query($sql, $this->_connection);
+ $query = mysql_query($sql, $this->connection);
EventLog::info("Executed [$sql]");
return (mysql_error() != '') ? $this->raiseError() : $query;
}

--
You received this message because you are subscribed to the Google Groups "Floe Commits" group.
To post to this group, send email to floe-c...@googlegroups.com.
To unsubscribe from this group, send email to floe-commits...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/floe-commits?hl=en.

Reply all
Reply to author
Forward
0 new messages