[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Очень долго выбираются данные из БД
Страницы: 1, 2
rooor
ты можешь целиком показать код, от начала выборки и до конца?
Игорь_Vasinsky
в этом запросе ничё ужасного нет.

у тя же есть связи между таблицами? с JOIN выборки делаешь? innoDB - а чё foregain key не используешь

_____________
HTML, CSS (Bootstrap), JS(JQuery, ExtJS), PHP, MySQL, MSSql, Posgres, (TSql, BI OLAP, MDX), Mongo, Git, SVN, CodeIgnater, Symfony, Yii 2, JiRA, Redmine, Bitbucket, Composer, Rabbit MQ, Amazon (SQS, S3, Transcribe), Docker
N0ob
Игорь_Vasinsky JOIN`ов не наблюдается.
rooor
index.php
<?php

$start = microtime(true);
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
header("Content-Type: text/html; charset=utf-8");

session_start();
define("KEY", true);
define("PATH", $_SERVER['DOCUMENT_ROOT']);

require PATH . "/engine/config.php";
require PATH . "/engine/core.php";
require PATH . "/engine/database.php";
require PATH . "/engine/template.php";
require PATH . "/engine/user.php";

if(!isset($_COOKIE['hash']))
{
setcookie("hash", "dfjgnfbaodgonapdrhnaijpapbj", time()+360*4*25*54+63*4);
$_COOKIE['hash'] = "dfjgnfbaodgonapdrhnaijpapbj";
}


$success_pages = Config::get("success_pages");
Core::get_page();
Core::get_hash();


if(in_array(Core::$current_page, $success_pages))
{
if(isset($_COOKIE['hash']))
{
Core::security();
Core::data();
require PATH . "/engine/modules/" . Core::$current_page . "/main.php";
}
else
{

Template::load("registration.php");
}
}

else
{
echo "Такой страницы нет " . Core::$current_page;
die();
}

$time = microtime(true) - $start;
printf('Скрипт выполнялся %.4F сек.', $time);

core.php
<?php if(!defined('KEY')) {header("Location: /404.html"); die();}


class Core
{
public static $current_page = "";
public static $user_hash = "";
public static $user_data = array();



public static function get_page()
{
if(empty(self::$current_page))
{
self::$current_page = isset($_GET['module']) ? trim($_GET['module']):"main";
}
}


public static function get_hash()
{
if(empty(self::$user_hash))
{
self::$user_hash = isset($_COOKIE['hash']) ? $_COOKIE['hash']:"";
}
}


public static function security()
{
$hash = self::$user_hash;

$select_user = Database::query("SELECT `id`, `nickname`, `rank_stady`, `rank_balls`, `avatar` FROM `fg5k_users` WHERE `hash`='".mysql_real_escape_string($hash)."'");
if(mysql_num_rows($select_user))
{
$user = mysql_fetch_assoc($select_user);
$sHonor = Database::query("SELECT `style`, `name`, `balls_next` FROM `fg5k_honors` WHERE `id`='".$user['rank_stady']."'");
$honor = mysql_fetch_assoc($sHonor);

self::$user_data[] = $user['id'];
self::$user_data[] = $user['nickname'];
self::$user_data[] = $user['rank_balls'];
self::$user_data[] = $user['avatar'];
self::$user_data[] = $honor['name'];
self::$user_data[] = $honor['balls_next'];
self::$user_data[] = $honor['style'];

Database::query("UPDATE `fg5k_users` SET `online`='1' WHERE `hash`='".mysql_real_escape_string($hash)."'");

}
else
{
setcookie("hash", "", time()-3600);
header("Location: /");
die();
}

return false;
}

public static function data()
{
if(!isset($_SESSION['id']) or !isset($_SESSION['nickname']) or !isset($_SESSION['honor_balls']) or !isset($_SESSION['honor_next_balls']) or !isset($_SESSION['avatar']) or !isset($_SESSION['honor_name']) or !isset($_SESSION['honor_style']))
{
$_SESSION['id'] = self::$user_data[0];
$_SESSION['nickname'] = self::$user_data[1];
$_SESSION['honor_balls'] = self::$user_data[2];
$_SESSION['avatar'] = self::$user_data[3];
$_SESSION['honor_name'] = self::$user_data[4];
$_SESSION['honor_next_balls'] = self::$user_data[5];
$_SESSION['honor_style'] = self::$user_data[6];
}

return false;
}

}

/modeules/main.php
<?php if(!defined('KEY')) {header("Location: /404.html"); die();}

$select_user = Database::query("SELECT `id`, `name`, `lastname`, `avatar`, `online`, `lastvisit`, `status`, `birthday`, `country`, `city`, `skype`, `email`, `twitter`, `facebook`, `website`, `edication`, `school`, `languages_for_programming`, year_for_programming FROM `fg5k_users` WHERE `hash`='".mysql_real_escape_string($_COOKIE['hash'])."'");
$user = mysql_fetch_assoc($select_user);
$select_photo = Database::query("SELECT `src` FROM `fg5k_photos` WHERE `author`='".$_SESSION['id']."'");

$main = Template::load("main.php", array('user'=>$user, 'photo'=>$select_photo));
echo Template::load("template.php", array('ctn'=>$main, 'title'=>$user['name'] . " <" . $_SESSION['nickname'] . "> " . $user['lastname']));
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.