[pLog-svn] r3275 - in plog/trunk: . class/database
class/database/pdb/drivers
mark at devel.lifetype.net
mark at devel.lifetype.net
Mon Apr 24 09:15:09 GMT 2006
Author: mark
Date: 2006-04-24 09:15:08 +0000 (Mon, 24 Apr 2006)
New Revision: 3275
Modified:
plog/trunk/class/database/db.class.php
plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
plog/trunk/wizard.php
Log:
According to the discuss with Oscar in mailing list, I move the "set names *" to pdbmysqldriver.class.php instead of db.class.php.
This place is more propriate for this kind of change.
Modified: plog/trunk/class/database/db.class.php
===================================================================
--- plog/trunk/class/database/db.class.php 2006-04-24 03:44:47 UTC (rev 3274)
+++ plog/trunk/class/database/db.class.php 2006-04-24 09:15:08 UTC (rev 3275)
@@ -42,12 +42,12 @@
$dbcharset = $fileConfig->getValue( "db_character_set" );
$dbpersistent = $fileConfig->getValue( "db_persistent" );
if($dbpersistent == true) {
- if( !$db->PConnect( $host, $username, $password, $dbname )) {
+ if( !$db->PConnect( $host, $username, $password, $dbname, $dbcharset )) {
die( "Fatal error: could not connect to the database!" );
}
}
else {
- if( !$db->Connect( $host, $username, $password, $dbname )) {
+ if( !$db->Connect( $host, $username, $password, $dbname, $dbcharset )) {
throw( new Exception( "Fatal error: could not connect to the database!" ));
die();
}
@@ -56,11 +56,6 @@
// by field number
//$db->SetFetchMode( ADODB_FETCH_ASSOC );
// comment out the line above if you're planning to test pdb
- if ( !empty( $dbcharset ) && $dbcharset != "default" )
- {
- $sql = "SET NAMES ".$dbcharset;
- $db->Execute( $sql );
- }
}
return $db;
Modified: plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php 2006-04-24 03:44:47 UTC (rev 3274)
+++ plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php 2006-04-24 09:15:08 UTC (rev 3275)
@@ -66,7 +66,7 @@
/**
* @see PDbDriverBase::Connect()
*/
- function Connect( $host, $username, $password, $dbname = null)
+ function Connect( $host, $username, $password, $dbname = null, $dbcharset = null )
{
PDbDriverBase::Connect( $host, $username, $password, $dbname );
@@ -75,6 +75,10 @@
if( !$this->_res )
return false;
+ // set the right character encoding for mysql 4.1+ client, connection and collation
+ if( !empty( $dbcharset ) && $dbcharset != "default" )
+ mysql_query( "SET NAMES ".$dbcharset, $this->_res );
+
// continue otherwise and try to select our db
if( $dbname )
return( mysql_select_db( $dbname, $this->_res ));
@@ -85,7 +89,7 @@
/**
* @see PDbDriverBase::PConnect()
*/
- function PConnect( $host, $username, $password, $dbname = null)
+ function PConnect( $host, $username, $password, $dbname = null, $dbcharset = null )
{
PDbDriverBase::Connect( $host, $username, $password, $dbname );
@@ -94,6 +98,10 @@
if( !$this->_res )
return false;
+ // set the right character encoding for mysql 4.1+ client, connection and collation
+ if( !empty( $dbcharset ) && $dbcharset != "default" )
+ mysql_query( "SET NAMES ".$dbcharset, $this->_res );
+
// continue otherwise and try to select our db
if( $dbname )
return( mysql_select_db( $dbname, $this->_res ));
Modified: plog/trunk/wizard.php
===================================================================
--- plog/trunk/wizard.php 2006-04-24 03:44:47 UTC (rev 3274)
+++ plog/trunk/wizard.php 2006-04-24 09:15:08 UTC (rev 3275)
@@ -100,19 +100,13 @@
// open a connection to the database
//$db = NewADOConnection('mysql');
$db = PDb::getDriver('mysql');
+
if ( $selectDatabase ) {
- $res = $db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ), $config->getValue( "db_database" ));
+ $res = $db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ), $config->getValue( "db_database" ), $config->getValue( "db_character_set" ));
} else {
- $res = $db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ));
+ $res = $db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ), null, $config->getValue( "db_character_set" ));
}
- $dbcharset = $config->getValue( "db_character_set" );
- if ( !empty( $dbcharset ) && $dbcharset != "default" )
- {
- $sql = "SET NAMES ".$dbcharset;
- $db->Execute( $sql );
- }
-
if( DB_WIZARD_DEBUG )
$db->debug = true;
More information about the pLog-svn
mailing list