PDO::TIME_ZONE and or Initializing Query
am 20.12.2007 16:40:21 von Paul Rogers
It would be helpful if the time zone of a session could be specified at
the time of the connection. This would avoid the overhead of a separate
database query and round-trip to the database server when a single,
non-default time zone is needed for the duration of the connection.
Naturally there is the option of using GMT and dealing with the time
zone offsets entirely in PHP or at some other layer. However, many large
databases systems support connection-specific time zones and I've found
them to be quite useful.
It may also be useful as a way to set the time zone after the connection
is made using "setAttribute".
Since several supported systems are not time-zone aware, such as Sqlite,
the attribute would not always have an effect. Or it could be
implemented as a server-specific attribute such as "MYSQL_TIME_ZONE" or
"PGSQL_TIME_ZONE".
If a TIME_ZONE attribute seems inappropriate then another idea is to
provide an optional, initialization query when creating the PDO object.
For example, a "SET TIME ZONE 'CST6CDT'" query could be issued to set
the time zone immediately after the connection is made. Such a mechanism
may have other uses for queries that do not require processing the
response.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: PDO::TIME_ZONE and or Initializing Query
am 21.12.2007 00:51:17 von dmagick
Paul Rogers wrote:
> It would be helpful if the time zone of a session could be specified at
> the time of the connection. This would avoid the overhead of a separate
> database query and round-trip to the database server when a single,
> non-default time zone is needed for the duration of the connection.
>
> Naturally there is the option of using GMT and dealing with the time
> zone offsets entirely in PHP or at some other layer. However, many large
> databases systems support connection-specific time zones and I've found
> them to be quite useful.
>
> It may also be useful as a way to set the time zone after the connection
> is made using "setAttribute".
>
> Since several supported systems are not time-zone aware, such as Sqlite,
> the attribute would not always have an effect. Or it could be
> implemented as a server-specific attribute such as "MYSQL_TIME_ZONE" or
> "PGSQL_TIME_ZONE".
>
> If a TIME_ZONE attribute seems inappropriate then another idea is to
> provide an optional, initialization query when creating the PDO object.
> For example, a "SET TIME ZONE 'CST6CDT'" query could be issued to set
> the time zone immediately after the connection is made. Such a mechanism
> may have other uses for queries that do not require processing the
> response.
I think the problem here is that each database type handles it all
differently, hence why you have to do it yourself.
If you want to put it to the developers, join the -internals list and
discuss the idea there.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php