Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to use the right timezone in a DBIx::Class ResultSet call?

by Your Mother (Archbishop)
on Aug 09, 2022 at 06:51 UTC ( [id://11146056]=note: print w/replies, xml ) Need Help??


in reply to How to use the right timezone in a DBIx::Class ResultSet call?

Untested; DBIx::Class::Manual::Intro. Couple other ways to do it. I would suggest that you probably really want it done in your ResultSet classes such that the TZ can be included with SQL functions at the point of running the query for individual users or locations; the best way would be to have the TZ available in a relationship otherwise you might have to resort to non-standard argument handling in the queries. This approach, obviously, sets it for all queries.

my $schema = YOUR::Schema->connect ("dbi:YourDBD:$DB_NAME", undef, undef, # credentials should never be hardcoded. { AutoCommit => 1, RaiseError => 1 }, { on_connect_do => "SET TIMEZONE='Australia/Sydney'" } );
  • Comment on Re: How to use the right timezone in a DBIx::Class ResultSet call?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to use the right timezone in a DBIx::Class ResultSet call?
by LittleJack (Beadle) on Aug 11, 2022 at 22:45 UTC

    Thanks so much, sorry for the delay in replying. I will test this right away.

      No trouble. If you want to share a little more about your DB and classes, I’d take a stab at showing the ResultSet class approach.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146056]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2026-02-07 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.