Execution requete sql prendre beaucoup de temps pour affichage

Fermé
hich - Modifié le 20 juil. 2017 à 19:45
jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 - 20 juil. 2017 à 21:21
Bonjour,

je veux faire jointure entre 5 table et afficher export json mais affichage json prendre beaucoup de temps pour affichage .
est e que il y a solution pour cette probleme?
voila code

<?php
header('Access-Control-Allow-Origin: *');

header('Content-type: application/json');
set_time_limit(0);

$connection = mysqli_connect("localhost","root","root","log") or die("Error " . mysqli_error($connection));

$sql = "select DISTINCT(p.ID) , p.post_title, p.post_content,p.post_date,p.post_modified , t.name,meta.meta_key,meta.meta_value,p.post_type,p.guid
from 2fix0r8f5_wp_posts p,2fix0r8f5_wp_term_relationships r,2fix0r8f5_wp_term_taxonomy tax , 2fix0r8f5_wp_terms t ,2fix0r8f5_wp_postmeta meta
WHERE p.ID = r.object_id AND r.term_taxonomy_id = tax.term_taxonomy_id AND t.term_id = tax.term_id AND meta.post_id = p.ID AND t.name = 'International'

GROUP BY p.ID
ORDER BY p.post_date DESC
LIMIT 50
";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
$emparray = array();
while($row =mysqli_fetch_assoc($result))
{
$emparray[] = array(
'ID' => $row['ID'],
'post_title' => utf8_encode($row["post_title"]),
'post_date' => $row["post_date"],
'name' => $row["name"],
'GUID' => $row["guid"],
'post_type' => $row["post_type"],
'post_modified' => $row["post_modified"],
'post_content' => utf8_encode($row["post_content"]),
'meta_key' => $row["meta_key"],
'meta_value' => 'media.medias-presse.info/wp-content/uploads/'.($row["meta_value"])


);
}
$a = json_encode($emparray, JSON_NUMERIC_CHECK);
echo $a;
mysqli_close($connection);
?>
A voir également:

1 réponse

jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
20 juil. 2017 à 21:21
Bonjour,

Le souci ne se trouve peut-être pas côté PHP ... mais plutôt au niveau de ta base de données ....
- As tu testé ta requête DIRECTEMENT dans ta bdd pour voir ce qu'elle donné ? (via phpmyadmin par exemple...)
- As tu mis des INDEX sur tes champs dans tes tables ?

0