| |
|
|
| | Пожалуйста объясните как можно увеличить скорость выполнения данного сценария:
<?php
/***************************************************************************
* index.php
* -------------------
* begin : Monday, Feb 27, 2005
* copyright : (C) 2004 The zcBB Group
* email : zcinc@mail.ru
*
* $Id: index.php,v 1.27.2.2 2005/03/1 Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
// Объявляем константы данного приложения
define('IN_ZCBB', true);
$page_title = 'zcBB :: Downloads :: Index';
$zcbb_root_path = './';
include ($zcbb_root_path . 'includes/extension.' . 'php');
// Вставляем шапку страницы
include ($zcbb_root_path . 'templates/overall_header.tpl');
// Соединяемся с базой данных MySQL
require_once ($zcbb_root_path . 'includes/db_connect.' . $phpEx);
// Вставляем библиотеку данного приложения
include ($zcbb_root_path . 'includes/libriary.' . $phpEx);
/****************************************************************************/
// Готовим запрос на выдирание данных о файалх из базы данных
$query_file = "SELECT *FROM downloads_files WHERE file_hide='show' ORDER BY file_put_date";
if ($sql_file = mysql_query($query_file)) {
while ($file = mysql_fetch_array($sql_file)) {
$file_id = $file['id_file'];
$file_name = $file['file_name'];
$file_size = $file['file_size'];
$query_link = "SELECT * FROM downloads_links WHERE id_link =".$file_id;
if ($sql_link = mysql_query($query_link)) {
while ($link = mysql_fetch_array($sql_link)) {
$link_id = $link['id_link'];
$link_url_text = $link['link_url_text'];
$link_url_address = $link['link_url_address'];
}
if (empty($link_url_text)|| empty($link_url_address)) {
$link_url_text = 'Отсутствует ссылка на файл';
$link_url_text = '';
}
}
else {
$link_url_text = 'Отсутствует ссылка на файл';
$link_url_text = '';
}
$query_comment = "SELECT * FROM downloads_comments WHERE comment_file_id =".$file_id;
if ($sql_comment = mysql_query($query_comment)) {
while ($comment = mysql_fetch_array($sql_comment)) {
$comment_id = $comment['id_comment'];
$comment_body_text = $comment['comment_body_text'];
}
if (empty($comment_body_text)) {
$comment_body_text = 'Отсутствуют комментарии';
}
}
else {
$comment_body_text = 'Отсутствуют комментарии';
}
echo "<table align'center' width='100%' class='body_line'>";
echo "<caption class='table_cell' align='left'> <b>".$file_name."</b></caption>";
echo "<tr class='table_sub_cell'>";
echo "<td>Имя файла: </td><td width='80%'>".$file_name."</td>";
echo "</tr>";
echo "<tr class='table_sub_cell'>";
echo "<td>Размер файла: </td><td width='80%'>".$file_size."</td>";
echo "</tr>";
echo "<tr class='table_body'>";
echo "<td colspan='2'><textarea cols='80' rows='11'>".$comment_body_text."</textarea></td>";
echo "<tr class='table_link_body'>";
echo "<td align='right' colspan='2'> <a href='".$link_url_address."'>".$link_url_text."</a> </td>";
echo "</tr>";
echo "</table><br><br>";
}
}
/****************************************************************************/
// Втавляем низ страницы
include ($zcbb_root_path . 'templates/overall_footer.tpl');
/****************************************************************************/
/****************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
?>
|
| |
| |
|
|
| |
|
|
| |
для: zc
(01.03.2005 в 18:10)
| | | Эм... а он медленно работает? ) | |
| |
|
|
| |
|
|
| |
для: Atom
(01.03.2005 в 19:49)
| | | Но и не быстро | |
| |
|
|
| |
|
|
| |
для: zc
(01.03.2005 в 18:10)
| | | 1) Избавится от вложенных запросов while, например организовав многотабличные запросы.
2) Столбец id_link проиндексирован? | |
| |
|
|
| |
|
|
| |
для: cheops
(01.03.2005 в 23:07)
| | | Если можете приведите примеры (на этом сценарии) многотабличного запроса | |
| |
|
|
| |
|
|
| |
для: zc
(02.03.2005 в 12:45)
| | | Только можно вопрос...? )
Почему я смотрю на скрипт и вижу phpBB? :) | |
| |
|
|
| |
автор: cheops (из ННГУ) (02.03.2005 в 14:42) |
|
| |
для: zc
(02.03.2005 в 12:45)
| | | Хм... а не могли бы вы структуру табличек привести... | |
| |
|
|
| |
|
|
| |
для: cheops (из ННГУ)
(02.03.2005 в 14:42)
| | | --
-- Структура таблицы 'downloads_comments'
--
CREATE TABLE 'downloads_comments' (
'id_comment' int(11) NOT NULL auto_increment,
'comment_file_id' int(11) NOT NULL default '0',
'comment_body_text' text NOT NULL,
PRIMARY KEY ('id_comment')
) TYPE=MyISAM AUTO_INCREMENT=3 ;
--
-- Структура таблицы 'downloads_files'
--
CREATE TABLE 'downloads_files' (
'id_file' int(11) NOT NULL auto_increment,
'file_name' text NOT NULL,
'file_size' text NOT NULL,
'file_hide' enum('show','hide') NOT NULL default 'show',
'file_put_date' datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY ('id_file')
) TYPE=MyISAM AUTO_INCREMENT=3 ;
--
-- Структура таблицы 'downloads_links'
--
CREATE TABLE 'downloads_links' (
'id_link' int(11) NOT NULL auto_increment,
'link_id_file' int(11) NOT NULL default '0',
'link_url_text' text NOT NULL,
'link_url_address' text NOT NULL,
PRIMARY KEY ('id_link')
) TYPE=MyISAM AUTO_INCREMENT=3 ;
--
-- Структура таблицы 'zcbb_info'
--
CREATE TABLE 'zcbb_info' (
'id_info' int(11) NOT NULL auto_increment,
'info_login' text NOT NULL,
'info_password' text NOT NULL,
'info_email' text NOT NULL,
'info_web_site' text NOT NULL,
'info_putdate' datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY ('id_info')
) TYPE=MyISAM AUTO_INCREMENT=2 ; | |
| |
|
|
| |
|
|
| |
для: zc
(02.03.2005 в 19:26)
| | | Кстати, стоп! А зачем вообще внутренние циклы while, если возвращается только одна строка? | |
| |
|
|