Re: DataObject: Overriding select syntax to include sql functions. MySQL convert_tz( )

From: Date: Wed, 02 Feb 2005 04:56:45 +0000
Subject: Re: DataObject: Overriding select syntax to include sql functions. MySQL convert_tz( )
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17326@lists.php.net to get a copy of this message
On Tue, 01 Feb 2005 18:46:57 +0000, JEnsign <justjohn@gmail.com> wrote: > Hi all, > > I am using MySQL and its timezone functions. > > I need a way to override ONLY the SQL selects used by some of my > dataobjects, so I can easily deal with date/time conversion per timezone. > Ideally, if I could just write something once in the parent class that > all my dataobjects extend that would be... well dreamy : ) > > Usage as: > > SELECT CONVERT_TZ( last_update,'UTC','America/Denver') from some_table; > > I hope im being clear : ) I need to inject sql functions into the sql > used by various dataobjects. > > Does anyone know how to insert sql function calls into the dataobjects > without having to manually write out the sql and use query( ) everytime? > What is the best approach to solving this? > Well...you could override find() and check the internal vars to see what columns are being selected. Check the types and if any are dates, replace their select SQL with yours. Then run parent::find(); There may be a better way to do it, though... -- Justin Patrin

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