mysql和php:在启动时设置配置变量 - 对服务器的影响?

mysql和php:在启动时设置配置变量 - 对服务器的影响?

问题描述:

date_default_timezone_set('America/Guayaquil');
$cnn->execute('SET NAMES utf8');
$cnn->execute('SET GLOBAL time_zone = "-5:00"');

Hi, the code above is run everytime someone enters the website im developing. Does someone know what the impact (in performance) of those commands is?

  date_default_timezone_set('America / Guayaquil'); 
 $ cnn-> execute('SET NAMES  utf8'); 
 $ cnn->执行('SET GLOBAL time_zone =“-5:00”'); 
  code>  pre> 
 
 

嗨,上面的代码是 每当有人进入我正在开发的网站时运行。 有人知道这些命令的影响(性能)是什么? p> div>

Of the PHP date_default_timezone_set command: negligible

Of the two MySQL commands: Unlikely to be significant.

Don't you mean SET SESSION rather than SET GLOBAL? If you're doing it for just the connection...

Edit: To expand on my answer, I have a script that gets included from just about every PHP script on my site that sets various configurations like date_default_timezone_set, starts sessions, defines functions and so on. It also sets the SQL mode to "TRADITIONAL" with the database connection. I think setting some configuration options is something you shouldn't try to avoid.