Re: DB_DataObject and specific mysql client encoding

From: Date: Mon, 28 Aug 2006 18:16:45 +0000
Subject: Re: DB_DataObject and specific mysql client encoding
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25008@lists.php.net to get a copy of this message
On 8/28/06, Markus Fischer <markus@fischer.name> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Justin Patrin wrote: On 8/28/06, Markus Fischer <markus@fischer.name> wrote:
I made a class "Custom_DB_DataObject extends DB_DataObject" and re-implemented _connect(). It's intersting that the real _connect() is marked as private which would prevent overriding it, luckily PEAR is PHP4 code so this is not enforced:
One other solution would be to create a DO (after you set up config, of course) then use getDatabaseConnection() to get the DB object, then run your query. You mean, every time and at every place I factor a DataObject, I run something like $DO->getDatabaseConnection()->query("SET NAMES ..."); ? But forgeting this at some point seems more error prone than having it part of DO ...
No, you only have to do this once for each database connection. I would suggest doing it in the code that sets up the configuration for your DOs. You *do* have that factored out, don't you? It also makes sense to put this in the DO class, as you did, I was just giving another possible solution which doesn't violate the private method. Then again, I hack private stuff in my own code (and even in a bit of PEAR code, but shhh, don't tell the QF devs). -- Justin Patrin

« previous php.pear.general (#25008) next »