0

I use "Medoo" as a database framework.

My problem is I'm in Brazil, but my database (which is MySQL) is in Los Angeles, meaning the timezone is different.

I use the NOW() function of the database a lot and everything is like Los Angeles time.

Eventually this causes me issues.

With pure PHP, I usually resolve this as follows, however, with Medoo I do not know how to resolve:

mysql_query ('SET time_zone = "America / Sao_Paulo"');
mysql_connect ("host", "user", "password") or
    die ("Could not connect:". mysql_error ());
mysql_select_db ("database");
$ result = mysql_query ("myquery");

Did you realize that before the query, I made a SET in time_zone ? I do not know how to do this in Medoo or even leave it at the definitive setting.

Anyone have ideas on how to solve this?

AymDev
  • 6,626
  • 4
  • 29
  • 52
  • [STOP using `mysql_*` functions](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – AymDev Aug 29 '18 at 11:21
  • @AymDev yes, mafriend! It's my old code... I am migrating to Medoo, but I do not know how to solve using Medoo. Do you know Medoo? I did not want to re-write SQL code in this software. So I'm trying to use Medoo to abstract SQL. Do you have any tips? Thank you, thank you! – Felipe Guimarães Pinto Aug 29 '18 at 11:30

1 Answers1

0

Check out the documentation about initialization. There is a command option that will be executed after database connected. You can set the timezone there.

$database = new Medoo([
    ...

    // [optional] Medoo will execute those commands after connected to the database for initialization
    'command' => [
        'SET SQL_MODE=ANSI_QUOTES'
    ]
]);
Angolao
  • 986
  • 1
  • 15
  • 27