[pLog-svn] RE: About the utf-8 support in mysql 4.1 (inlcude 5.x)

Oscar Renalias oscar at renalias.net
Sun Apr 23 21:44:54 GMT 2006


I'm actually thinking that it probably isn't a good idea to add an
additional SQL query for every query that we execute, only to set the
character set.

If it's something that we can do right away when opening the
connection, let's do it like that. If it requires changes to
wizard.php, the configuration file and the database drivers, now's the
time to do it.

We can always modify the PDbDriverBase::Connect and
PDbDriverBase::PConnect methods to take an extra parameter defining
the character encoding. If not present, then it should not have any
effect (i.e. we won't set any encoding by default) Likewise, if
database encoding data cannot be found in the configuration file,
nothing should be done about it.

Then each driver should get the character encoding information and run
the necessary queries/commands to activate it.

You can go ahead with the changes or I can try to take a look at it
when I have the time.

Oscar

On 4/22/06, Mark Wu <markplace at gmail.com> wrote:
>
> Here comes the method 1 implementation.
>
> This is really easy. Just overwrite the  pdbmysqldriver.class.php is okay.
>
> We don;t need to change wizard.php, db.class.php ....blahblah ...
>
> If those parameters check does not impact performance much, I think this
> implementation is easier then the method 2, and also make the code clear.
>
> Mark
>
>
>  ________________________________
>  From: Mark Wu [mailto:markplace at gmail.com]
> Sent: Saturday, April 22, 2006 11:36 PM
> To: 'plog-svn at devel.lifetype.net'
> Subject: About the utf-8 support in mysql 4.1 (inlcude 5.x)
>
>
>
> Hi All:
>
> I am thinking port pesty's adodb-mysql-driver utf-8 patch to our pdb, but
> need your suggestions.
>
> There are two ways to add the support:
>
> Method 1. Use the same way that pesty did. We can add isSupportUtf8() and
> getDbDefaultEncoding() to our mysql pdb driver. And check those parameters
> in every query. See the following code:
>
>         if ($this->_isSupportUtf8() && $argDatabasename) {
>             $dbEncoding =
> $this->_getDbDefaultEncoding($argDatabasename);
>             if ($dbEncoding) {
>                 mysql_query("SET NAMES $dbEncoding", $this->_connectionID);
>             }
>         }
>
> pros: It is easy to do, and we don't need to change any current code
>
> cons: It will decrease the performance, if we support a huge site. (It is
> only my wild guess).
>
>
> Method 2. We add a new config value "db_character_set" to our config file.
> And we can determine the character set in the installation time and write it
> back to config files.
>
> pros: We don't need to check those parameters everytime, just get it from
> our config file.
>
> cons: We need to change some code in wizard.php and db.clss.php to meet this
> need. And these codes are not db-independent. So ... these modification
> maybe made our code looks ugly
>
> I already implement method 2. If you want to test, just overwrite the
> current trunk with the files in patch.zip. You will  see it.
>
> So, let me know which way you like it.
>
> ** I personally like way 2, but it makes the code hard to port to another
> database platfrom.
>
> Mark
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>
>
>


More information about the pLog-svn mailing list