13-12-2008, 09:30 PM
Bonjour,
J'ai un gros problème, ma map possède beaucoup trop de requêtes sql, ce qui cause des problèmes, car je dépasse la limite de connexion autorisé sur l'hébergeur quand il y a plus de 15 connectés simultané.
Voila les requetes problématique :
J'ai un gros problème, ma map possède beaucoup trop de requêtes sql, ce qui cause des problèmes, car je dépasse la limite de connexion autorisé sur l'hébergeur quand il y a plus de 15 connectés simultané.
Voila les requetes problématique :
Code PHP :
<?php
//Récupération élément décors.
$mapquery = doquery("SELECT longitude, latitude, pic, land FROM {{table}} WHERE longitude between $x_start and $x_end AND latitude between $y_start and $y_end ORDER BY longitude DESC,latitude DESC LIMIT 48", "map");
while ($maprow = mysql_fetch_assoc($mapquery)) {
if (empty($TabMAP1[$maprow['longitude']][$maprow['latitude']]))
$TabMAP1[$maprow['longitude']][$maprow['latitude']] = $maprow['pic'];
}
mysql_free_result($mapquery);
//Récupération élément clans.
$clanquery = doquery("SELECT pic, longitude, latitude FROM {{table}} WHERE longitude between $x_start and $x_end AND latitude between $y_start and $y_end ORDER BY longitude DESC,latitude DESC LIMIT 48", "clans_elements");
while ($clanrow = mysql_fetch_assoc($clanquery)) {
if (empty($TabMAP7[$clanrow['longitude']][$clanrow['latitude']]))
$TabMAP7[$clanrow['longitude']][$clanrow['latitude']] = $clanrow['pic'];
}
mysql_free_result($clanquery);
//Récupération élément villes.
$townquery = doquery("SELECT name, longitude, latitude FROM {{table}} WHERE longitude between $x_start and $x_end AND latitude between $y_start and $y_end ORDER BY longitude DESC,latitude DESC LIMIT 48", "towns");
while ($townrow = mysql_fetch_assoc($townquery)) {
if (empty($TabMAP2[$townrow['longitude']][$townrow['latitude']]))
$TabMAP2[$townrow['longitude']][$townrow['latitude']] = $townrow['name'];
}
mysql_free_result($townquery);
//Récupération élément points de téléportations.
$teleportationquery = doquery("SELECT name, longitude, latitude FROM {{table}} WHERE longitude between $x_start and $x_end AND latitude between $y_start and $y_end ORDER BY longitude DESC,latitude DESC LIMIT 48", "teleportations");
while ($teleportationrow = mysql_fetch_assoc($teleportationquery)) {
if (empty($TabMAP9[$teleportationrow['longitude']][$teleportationrow['latitude']]))
$TabMAP9[$teleportationrow['longitude']][$teleportationrow['latitude']] = $teleportationrow['name'];
}
mysql_free_result($teleportationquery);
//Récupération élément bureaux des colis.
$officequery = doquery("SELECT name, longitude, latitude FROM {{table}} WHERE longitude between $x_start and $x_end AND latitude between $y_start and $y_end ORDER BY longitude DESC,latitude DESC LIMIT 48", "packages_offices");
while ($officerow = mysql_fetch_assoc($officequery)) {
if (empty($TabMAP8[$officerow['longitude']][$officerow['latitude']]))
$TabMAP8[$officerow['longitude']][$officerow['latitude']] = $officerow['name'];
}
mysql_free_result($officequery);
//Récupération élément coffres.
$cofferquery = doquery("SELECT name, longitude, latitude FROM {{table}} WHERE longitude between $x_start and $x_end AND latitude between $y_start and $y_end ORDER BY longitude DESC,latitude DESC LIMIT 48", "coffers");
while ($cofferrow = mysql_fetch_assoc($cofferquery)) {
if (empty($TabMAP5[$cofferrow['longitude']][$cofferrow['latitude']]))
$TabMAP5[$cofferrow['longitude']][$cofferrow['latitude']] = $cofferrow['name'];
}
mysql_free_result($cofferquery);
//Recupération des autres joueurs
$playersquery = doquery("SELECT id, charname, avatar, longitude, latitude FROM {{table}} WHERE longitude between $x_start and $x_end AND latitude between $y_start and $y_end AND id!='$userrow[id]' AND UNIX_TIMESTAMP(onlinetime) >= '".(time()-120)."' AND (currentaction='En exploration' OR currentaction='En combat') ORDER BY longitude DESC,latitude DESC LIMIT 48", "users");
while ($playersrow = mysql_fetch_assoc($playersquery)) {
if (empty($TabMAP3[$playersrow['longitude']][$playersrow['latitude']]))
$TabMAP3[$playersrow['longitude']][$playersrow['latitude']] = $playersrow['avatar'];
$TabMAP4[$playersrow['longitude']][$playersrow['latitude']] = $playersrow['charname'];
}
mysql_free_result($playersquery);
Pour ceux qui comprennent pas doquery()
Code PHP :
<?php
function doquery($query, $table) {
include('config.php');
$sqlquery = mysql_query(str_replace("{{table}}", $dbsettings["prefix"] . "_" . $table, $query)) or die(mysql_error());
return $sqlquery;
}