Skip to content
Extraits de code Groupes Projets
Valider 9c1bd8a6 rédigé par esj's avatar esj
Parcourir les fichiers

Tâche #209: normalisation des appels de spip_query

parent e4a2be1e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -33,8 +33,8 @@ global ...@@ -33,8 +33,8 @@ global
$id_breve = intval($id_breve); $id_breve = intval($id_breve);
if ($new != "oui") { if ($new != "oui") {
$query = "SELECT * FROM spip_breves WHERE id_breve=$id_breve"; $result = spip_query("SELECT * FROM spip_breves WHERE id_breve=$id_breve");
$result = spip_query($query);
if ($row=spip_fetch_array($result)) { if ($row=spip_fetch_array($result)) {
$id_breve=$row['id_breve']; $id_breve=$row['id_breve'];
...@@ -109,8 +109,8 @@ if ($connect_statut=="0minirezo" OR $statut=="prop" OR $new == "oui") { ...@@ -109,8 +109,8 @@ if ($connect_statut=="0minirezo" OR $statut=="prop" OR $new == "oui") {
if ($id_rubrique == 0) $logo_parent = "racine-site-24.gif"; if ($id_rubrique == 0) $logo_parent = "racine-site-24.gif";
else { else {
$query = "SELECT id_parent FROM spip_rubriques WHERE id_rubrique='$id_rubrique'"; $result=spip_query("SELECT id_parent FROM spip_rubriques WHERE id_rubrique='$id_rubrique'");
$result=spip_query($query);
while($row=spip_fetch_array($result)){ while($row=spip_fetch_array($result)){
$parent_parent=$row['id_parent']; $parent_parent=$row['id_parent'];
} }
......
...@@ -24,8 +24,8 @@ function afficher_breves_voir($id_breve, $changer_lang, $cherche_mot, $supp_mot, ...@@ -24,8 +24,8 @@ function afficher_breves_voir($id_breve, $changer_lang, $cherche_mot, $supp_mot,
{ {
global $champs_extra, $options, $connect_statut, $les_notes; global $champs_extra, $options, $connect_statut, $les_notes;
$query = "SELECT * FROM spip_breves WHERE id_breve='$id_breve'"; $result = spip_query("SELECT * FROM spip_breves WHERE id_breve='$id_breve'");
$result = spip_query($query);
if ($row = spip_fetch_array($result)) { if ($row = spip_fetch_array($result)) {
$id_breve=$row['id_breve']; $id_breve=$row['id_breve'];
......
...@@ -44,8 +44,7 @@ debut_droite(); ...@@ -44,8 +44,7 @@ debut_droite();
while ($row = spip_fetch_array($res)) while ($row = spip_fetch_array($res))
$types[$row['id_type']] = $row; $types[$row['id_type']] = $row;
$query = "SELECT docs.id_document AS id_doc, docs.id_type AS type, docs.fichier AS fichier, docs.date AS date, docs.titre AS titre, docs.descriptif AS descriptif, lien.id_rubrique AS id_rub, rubrique.titre AS titre_rub FROM spip_documents AS docs, spip_documents_rubriques AS lien, spip_rubriques AS rubrique WHERE docs.id_document = lien.id_document AND rubrique.id_rubrique = lien.id_rubrique AND docs.mode = 'document' ORDER BY docs.date DESC"; $result = spip_query("SELECT docs.id_document AS id_doc, docs.id_type AS type, docs.fichier AS fichier, docs.date AS date, docs.titre AS titre, docs.descriptif AS descriptif, lien.id_rubrique AS id_rub, rubrique.titre AS titre_rub FROM spip_documents AS docs, spip_documents_rubriques AS lien, spip_rubriques AS rubrique WHERE docs.id_document = lien.id_document AND rubrique.id_rubrique = lien.id_rubrique AND docs.mode = 'document' ORDER BY docs.date DESC");
$result = spip_query($query);
while($row=spip_fetch_array($result)){ while($row=spip_fetch_array($result)){
$titre=$row['titre']; $titre=$row['titre'];
......
...@@ -24,17 +24,11 @@ function extraire_article($id_p) { ...@@ -24,17 +24,11 @@ function extraire_article($id_p) {
function gen_liste_rubriques() { function gen_liste_rubriques() {
// se restreindre aux rubriques utilisees recemment +secteurs // se restreindre aux rubriques utilisees recemment +secteurs
$liste="0"; $liste="0";
$s = spip_query("SELECT id_rubrique FROM spip_rubriques $s = spip_query("SELECT id_rubrique FROM spip_rubriques ORDER BY id_parent=0 DESC, date DESC LIMIT 500");
ORDER BY id_parent=0 DESC, date DESC LIMIT 500");
while ($t = spip_fetch_array($s)) while ($t = spip_fetch_array($s))
$liste .=",".$t['id_rubrique']; $liste .=",".$t['id_rubrique'];
$q = "SELECT id_rubrique, id_parent, titre $res = spip_query("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE id_rubrique IN ($liste) ORDER BY id_parent,0+titre,titre");
FROM spip_rubriques
WHERE id_rubrique IN ($liste)
ORDER BY id_parent,0+titre,titre";
$res = spip_query($q);
$GLOBALS['db_art_cache'] = array(); $GLOBALS['db_art_cache'] = array();
if (spip_num_rows($res) > 0) { if (spip_num_rows($res) > 0) {
......
...@@ -17,8 +17,8 @@ function exec_sites_edit_dist() ...@@ -17,8 +17,8 @@ function exec_sites_edit_dist()
{ {
global $champs_extra, $connect_statut, $descriptif, $id_rubrique, $id_secteur, $id_syndic, $new, $nom_site, $syndication, $url_site, $url_syndic; global $champs_extra, $connect_statut, $descriptif, $id_rubrique, $id_secteur, $id_syndic, $new, $nom_site, $syndication, $url_site, $url_syndic;
$query = "SELECT * FROM spip_syndic WHERE id_syndic=" . intval($id_syndic); $result = spip_query("SELECT * FROM spip_syndic WHERE id_syndic=" . intval($id_syndic));
$result = spip_query($query);
if ($row = spip_fetch_array($result)) { if ($row = spip_fetch_array($result)) {
$id_syndic = $row["id_syndic"]; $id_syndic = $row["id_syndic"];
$id_rubrique = $row["id_rubrique"]; $id_rubrique = $row["id_rubrique"];
...@@ -101,8 +101,8 @@ echo "<input type='text' class='formo' name='url_site' value=\"$url_site\" size= ...@@ -101,8 +101,8 @@ echo "<input type='text' class='formo' name='url_site' value=\"$url_site\" size=
if ($id_rubrique == 0) $logo_parent = "racine-site-24.gif"; if ($id_rubrique == 0) $logo_parent = "racine-site-24.gif";
else { else {
$query = "SELECT id_parent FROM spip_rubriques WHERE id_rubrique='$id_rubrique'"; $result=spip_query("SELECT id_parent FROM spip_rubriques WHERE id_rubrique='$id_rubrique'");
$result=spip_query($query);
while($row=spip_fetch_array($result)){ while($row=spip_fetch_array($result)){
$parent_parent=$row['id_parent']; $parent_parent=$row['id_parent'];
} }
......
...@@ -62,8 +62,8 @@ if ($connect_statut != '0minirezo') { ...@@ -62,8 +62,8 @@ if ($connect_statut != '0minirezo') {
debut_cadre_enfonce("langues-24.gif"); debut_cadre_enfonce("langues-24.gif");
$query = "SELECT SUM(".$critere.") AS total_visites FROM spip_articles"; $result = spip_query("SELECT SUM(".$critere.") AS total_visites FROM spip_articles");
$result = spip_query($query);
$visites = 1; $visites = 1;
if ($row = spip_fetch_array($result)) if ($row = spip_fetch_array($result))
$total_visites = $row['total_visites']; $total_visites = $row['total_visites'];
...@@ -71,10 +71,7 @@ debut_cadre_enfonce("langues-24.gif"); ...@@ -71,10 +71,7 @@ debut_cadre_enfonce("langues-24.gif");
$total_visites = 1; $total_visites = 1;
echo "<p>"; echo "<p>";
$result = spip_query("SELECT lang, SUM(".$critere.") AS cnt FROM spip_articles WHERE statut='publie' GROUP BY lang");
$query = "SELECT lang, SUM(".$critere.") AS cnt FROM spip_articles WHERE statut='publie' GROUP BY lang";
$result = spip_query($query);
echo "<table cellpadding = 2 cellspacing = 0 border = 0 width='100%' style='border: 1px solid #aaaaaa;'>"; echo "<table cellpadding = 2 cellspacing = 0 border = 0 width='100%' style='border: 1px solid #aaaaaa;'>";
$ifond = 1; $ifond = 1;
......
...@@ -20,16 +20,14 @@ function exec_statistiques_referers_dist() ...@@ -20,16 +20,14 @@ function exec_statistiques_referers_dist()
global $connect_statut, $id_article, $jour, $limit; global $connect_statut, $id_article, $jour, $limit;
if ($id_article = intval($id_article)){ if ($id_article = intval($id_article)){
$query = "SELECT titre, visites, popularite FROM spip_articles WHERE statut='publie' AND id_article ='$id_article'"; $result = spip_query("SELECT titre, visites, popularite FROM spip_articles WHERE statut='publie' AND id_article ='$id_article'");
$result = spip_query($query);
if ($row = spip_fetch_array($result)) { if ($row = spip_fetch_array($result)) {
$total_absolu = $row['visites']; $total_absolu = $row['visites'];
} }
} }
else { else {
$query = "SELECT SUM(visites) AS total_absolu FROM spip_visites"; $result = spip_query("SELECT SUM(visites) AS total_absolu FROM spip_visites");
$result = spip_query($query);
if ($row = spip_fetch_array($result)) { if ($row = spip_fetch_array($result)) {
$total_absolu = $row['total_absolu']; $total_absolu = $row['total_absolu'];
......
...@@ -22,15 +22,15 @@ function enfants($id_parent, $critere){ ...@@ -22,15 +22,15 @@ function enfants($id_parent, $critere){
global $nombre_abs; global $nombre_abs;
$query = "SELECT id_rubrique FROM spip_rubriques WHERE id_parent='$id_parent'"; $result = spip_query("SELECT id_rubrique FROM spip_rubriques WHERE id_parent='$id_parent'");
$result = spip_query($query);
$nombre = 0; $nombre = 0;
while($row = spip_fetch_array($result)) { while($row = spip_fetch_array($result)) {
$id_rubrique = $row['id_rubrique']; $id_rubrique = $row['id_rubrique'];
$query2 = "SELECT SUM(".$critere.") AS cnt FROM spip_articles WHERE id_rubrique='$id_rubrique'"; $result2 = spip_query("SELECT SUM(".$critere.") AS cnt FROM spip_articles WHERE id_rubrique='$id_rubrique'");
$result2 = spip_query($query2);
$visites = 0; $visites = 0;
if ($row2 = spip_fetch_array($result2)) { if ($row2 = spip_fetch_array($result2)) {
$visites = $row2['cnt']; $visites = $row2['cnt'];
...@@ -55,9 +55,7 @@ function enfants_aff($id_parent,$decalage, $critere, $gauche=0) { ...@@ -55,9 +55,7 @@ function enfants_aff($id_parent,$decalage, $critere, $gauche=0) {
global $abs_total; global $abs_total;
global $taille; global $taille;
$query="SELECT id_rubrique, titre, descriptif FROM spip_rubriques WHERE id_parent='$id_parent' ORDER BY 0+titre, titre"; $result=spip_query("SELECT id_rubrique, titre, descriptif FROM spip_rubriques WHERE id_parent='$id_parent' ORDER BY 0+titre, titre");
$result=spip_query($query);
while($row = spip_fetch_array($result)){ while($row = spip_fetch_array($result)){
$id_rubrique = $row['id_rubrique']; $id_rubrique = $row['id_rubrique'];
......
...@@ -76,16 +76,14 @@ echo '</defs>'; ...@@ -76,16 +76,14 @@ echo '</defs>';
$where = "0=0"; $where = "0=0";
} }
$query="SELECT UNIX_TIMESTAMP(date) AS date_unix FROM $table ". $result = spip_query("SELECT UNIX_TIMESTAMP(date) AS date_unix FROM $table WHERE $where ORDER BY date LIMIT 1");
"WHERE $where ORDER BY date LIMIT 1";
$result = spip_query($query);
while ($row = spip_fetch_array($result)) { while ($row = spip_fetch_array($result)) {
$date_premier = $row['date_unix']; $date_premier = $row['date_unix'];
} }
$query="SELECT UNIX_TIMESTAMP(date) AS date_unix, visites FROM $table ". $result = spip_query("SELECT UNIX_TIMESTAMP(date) AS date_unix, visites FROM $table WHERE $where AND date > DATE_SUB(NOW(),INTERVAL $aff_jours DAY) ORDER BY date");
"WHERE $where AND date > DATE_SUB(NOW(),INTERVAL $aff_jours DAY) ORDER BY date";
$result=spip_query($query);
while ($row = spip_fetch_array($result)) { while ($row = spip_fetch_array($result)) {
$date = $row['date_unix']; $date = $row['date_unix'];
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter