RE: [PEAR] DB/DB_DataObject and MySQL character sets
| From: | Denis Gerasimov | Date: | Thu, 16 Dec 2004 07:06:03 +0000 |
| Subject: | RE: [PEAR] DB/DB_DataObject and MySQL character sets | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16266@lists.php.net to get a copy of this message | ||
Many thanks to everyone discussing this problem.
But nothing of suggested is what I need.
1. Configuration I use
(my own development PC)
Operating System: MS Windows XP Professional
Web server: Apache HTTP Server 2.0.52
PHP version: PHP 5.0.2
MySQL version: MySQL 4.1.7
2. my.ini snip
default-character-set=cp1251
3. database.ini snip
[DB_DataObject]
database = mysqli://user:pass@localhost/mydb
; the default database dsn see pear spec for more details
4. mysqli ext.
libmysqli.dll library _bundled_ with PHP 5.0.2 (resides in PHP root dir)
Thanks Justin, but I know this 'hack' (and also I understand that I need to
excute this query only once for the connection to mydb no matter how much
instances of DO I have).
The thing is that this hack supposes refactoring of all existing code to
comply with new MySQL version. That is why I am looking for an easier way to
solve this problem.
So I see only two suitable ways:
1. Force MySQL to use my codepage by default for new connections (which
way?). I tried its command-line utility to connect manually to the server
and it showed me that connection codepage is latin1.
2. Tell DB or DB_DataObject someway to set required connection codepage. The
only method which I see is identical to Justin's one.
Any more ideas?
Best regards, Denis Gerasimov
Outsourcing Services Manager,
VEKOS, Ltd.
www.vekos.ru
> -----Original Message-----
> From: Justin Patrin [mailto:papercrane@gmail.com]
> Sent: Wednesday, December 15, 2004 3:30 AM
> To: Ken Restivo
> Cc: Denis Gerasimov; PEAR General List
> Subject: Re: [PEAR] DB/DB_DataObject and MySQL character sets
>
> On Tue, 14 Dec 2004 16:26:58 -0800, Ken Restivo <ken@restivo.org> wrote:
> > On Tue, Dec 14, 2004 at 09:13:29AM -0800, Justin Patrin wrote:
> > > > default-character-set=cp1251
> > > >
> > > > in my.ini, but it didn't help me.
> > > >
> > >
> > > Here's a quick hac for you. After including your ini file, get a DO
> > > and set the charset.
> > >
> > > $do = DB_DataObject::factory('someTable');
> > > $do->query('SET CHARACTER SET cp1251');
> > >
> >
> > Does this need to be done in the initialisation of *every* DO?
> >
> > Or is there some way to set the character set via a static method, and
> have it apply globally?
> >
>
> You should only need to do this once for each connection, so at the
> top of the script (or the beginning of your DB_DataObject usage).
>
> > I haven't seen this problem yet, but my ISP just upgraded to MySQL 4.1,
> and I've already seen other weird problems in other areas, so I'm worried.
> >
>
> AHA! As another poster said, Mysql 4 is different than earlier
> versions. Try changing your connect DSN to use mysqli instead of mysql
> (note the extra i). If PHP doesn't have the mysqli extension
> installed, tell your ISP you need it for Mysql 4.
>
> --
> Justin Patrin
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php