Le 22/08/2009 17:21, Pi r a écrit :
j'ai testé sur deux serveurs différents php4 mysql 5.0.20 et php5 mysql
5.0.51
en spip 2.09 vierge avec juste cfg et notation
la boucle (DOCUMENTS){id_article}{notation){!par moyenne}
j'ai le même message d'erreur
--> Unknown column 'notations.note'
OK, on vient de confirmer le bug : pour tester :
+ cfg, notations, et squelette basique avec des documents :
<BOUCLE_art(ARTICLES){!par date}>
<br />ida #ID_ARTICLE : #TITRE<br />
<BOUCLE_docs(DOCUMENTS){id_article}{notation}{mode IN document,image}{!par moyenne}>
id #ID_DOCUMENT titre #TITRE<br />
</BOUCLE_docs>
</BOUCLE_art>
La requete générée n'a pas la table «notations» dans les FROM et génère une erreur :
SELECT
COUNT(notations.note) AS nombre_votes,
ROUND(AVG(notations.note),2) AS moyenne,
ROUND(AVG(notations.note)*(1-EXP(-5*COUNT(notations.note)/1)),2) AS moyenne_ponderee,
documents.id_document,
documents.titre
FROM spip_documents AS `documents`
LEFT JOIN spip_documents_liens AS l ON documents.id_document=l.id_document
LEFT JOIN spip_articles AS aa ON (l.id_objet=aa.id_article AND l.objet='article')
LEFT JOIN spip_breves AS bb ON (l.id_objet=bb.id_breve AND l.objet='breve')
LEFT JOIN spip_rubriques AS rr ON (l.id_objet=rr.id_rubrique AND l.objet='rubrique')
LEFT JOIN spip_forum AS ff ON (l.id_objet=ff.id_forum AND l.objet='forum')
INNER JOIN spip_documents_liens AS L1 ON ( L1.id_document = documents.id_document )
WHERE ((aa.statut = 'publie' AND aa.date<='9999-12-31') OR bb.statut = 'publie' OR rr.statut = 'publie' OR ff.statut='publie')
AND (documents.taille > 0 OR documents.distant='oui')
AND (L1.id_objet = 22) AND (L1.objet = 'article')
AND ((documents.mode IN ('document','image')))
GROUP BY documents.id_document,documents.id_document
ORDER BY moyenne DESC
Unknown column 'notations.note' in 'field list'
-----------------------------------------
Solution bancale : activer «médiathèque»
----------------------------------------
Par contre, activer le plugin gestion_documents (médiathèque) résous le problème, la requete devient correcte. POURQUOI donc ?
SELECT
COUNT(notations.note) AS nombre_votes,
ROUND(AVG(notations.note),2) AS moyenne,
ROUND(AVG(notations.note)*(1-EXP(-5*COUNT(notations.note)/30)),2) AS moyenne_ponderee,
documents.id_document,
documents.titre
FROM spip_documents AS `documents`
LEFT JOIN spip_notations AS notations ON (notations.id_objet=documents.id_document AND notations.objet='document')
INNER JOIN spip_documents_liens AS L1 ON ( L1.id_document = documents.id_document )
WHERE ((documents.statut = "publie"))
AND (documents.date_publication < '9999-12-31')
AND (documents.taille > 0 OR documents.distant='oui')
AND (L1.id_objet = 2)
AND (L1.objet = 'article')
AND ((documents.mode IN ('document','image')))
GROUP BY documents.id_document
ORDER BY moyenne DESC
Cédric, tu as une idée de pourquoi ta requête est plus courte, jolie, fonctionnelle et intelligente ?
--
MM.