Jump to content
  • 0

Что больше нагрузит сервер


stalker_2000
 Share

Question

Приветствую! Подскажите, какой из нижеприведенного кода будет легче с точки зрения нагрузки и потребления памяти сервером:

1)

if (defined('URI_LOG_ON'))
{
mysql_query("INSERT INTO get_log VALUES('{$_SERVER['REQUEST_URI']}')");
if ($_SERVER['REQUEST_METHOD']==='POST')
{
foreach($_POST as $k=>$v) mysql_query("INSERT INTO post_log VALUES('{$k}','{$v}')");
}
}

2)

if (defined('URI_LOG_ON'))
{
$log_file = fopen('uri.log','a+');
fwrite($log_file,date('d-m-Y, H-i-s').': '.$_SERVER['REQUEST_URI']."\n");
fclose($log_file);
if ($_SERVER['REQUEST_METHOD']==='POST')
{
$log_file = fopen('uri_post.log','a+');
fwrite($log_file,date('d-m-Y, H-i-s')." ======================================\n");
foreach($_POST as $k=>$v)
{
fwrite($log_file,"{$k}={$v}"."\n");
}
fclose($log_file);
}
}

Edited by stalker_2000
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
Приветствую! Подскажите, какой из нижеприведенного кода будет легче с точки зрения нагрузки и потребления памяти сервером:

1)

if (defined('URI_LOG_ON'))
{
mysql_query("INSERT INTO get_log VALUES('{$_SERVER['REQUEST_URI']}')");
if ($_SERVER['REQUEST_METHOD']==='POST')
{
foreach($_POST as $k=>$v) mysql_query("INSERT INTO post_log VALUES('{$k}','{$v}')");
}
}

2)

if (defined('URI_LOG_ON'))
{
$log_file = fopen('uri.log','a+');
fwrite($log_file,date('d-m-Y, H-i-s').': '.$_SERVER['REQUEST_URI']."\n");
fclose($log_file);
if ($_SERVER['REQUEST_METHOD']==='POST')
{
$log_file = fopen('uri_post.log','a+');
fwrite($log_file,date('d-m-Y, H-i-s')." ======================================\n");
foreach($_POST as $k=>$v)
{
fwrite($log_file,"{$k}={$v}"."\n");
}
fclose($log_file);
}
}

2. хотите решить что лучше изпользовать: базу или файлы? так я вам отвечаю - базу.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy