J'utilise un module Joomla (ArogaRousel) qui a été créé pour afficher les images d'un autre module (AdsManager), et le module affiche l'erreur suivante:Utilisation du module Joomla et erreur "Pas de connexion valide à la base de données Vous avez> une erreur dans votre syntaxe SQL"
No valid database connection You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ORDER BY views DESC, id LIMIT 0, 9' at line 1 SQL=SELECT *,concat('/images/com_adsmanager/ads/',id,'a.jpg') as imgUrl FROM root_adsmanager_ads , root_adsmanager_adcat as ac WHERE published=1 AND (ac.adid=id and ac.catid IN()) ORDER BY views DESC, id LIMIT 0, 9
Je ne suis pas compétent dans MySQL, mais je l'ai trouvé le fichier dans lequel la requête est faite.
Ceci est le code où la requête est faite
$query = "SELECT *,concat('/images/com_adsmanager/ads/',id,'a.jpg') as imgUrl FROM #__adsmanager_ads "
. $table
. " WHERE published=1 "
. $where
. $ordering
. $limit;
Pourrait-vous, ô homme bien informés, indiquer l'erreur et la solution?
En réponse à Bemace ici, j'ajouter toute la fonction
// Get list of banners
function getAds(&$paramslist){
$where = array();
if ($paramslist['ads'] != '') $where[] = 'id IN (' . modArogarouselAdsmanagerHelper::cleanIds($paramslist['ads']) . ')';
if ($paramslist['categories'] != '') {
$where[] = 'ac.adid=id and ac.catid IN (' . modArogarouselAdsmanagerHelper::cleanIds($paramslist['categories']) . ')';
$table = ' , #__adsmanager_adcat as ac';
}
$where = (count($where) > 0) ? ' AND (' . implode(' OR ', $where) . ')' : '';
if ($paramslist['ordering'] == 1) {
$ordering = ' ORDER BY views DESC, id';
} else if ($paramslist['ordering'] == 2) {
$ordering = ' ORDER BY views ASC';
} else if ($paramslist['ordering'] == 3) {
$ordering = ' ORDER BY id';
} else if ($paramslist['ordering'] == 4) {
$ordering = ' ORDER BY RAND()';
}
$limit = ($paramslist['limit'] != '') ? ' LIMIT 0, ' . ($paramslist['limit']) : '';
$query = "SELECT *,concat('/images/com_adsmanager/ads/',id,'a.jpg') as imgUrl FROM #__adsmanager_ads "
. $table
. " WHERE published=1 "
. $where
. $ordering
. $limit;
$db = &JFactory::getDBO();
$db->setQuery($query);
$adslist = $db->loadObjectList();
$adslist = ($paramslist['mode_dir'] == 'bottom') ? array_reverse($adslist, true) : $adslist;
//print_r($adslist);
return $adslist;
}
J'ai ajouté toute la fonctionnalité ci-dessus, je ne peux pas dans les commentaires, je suppose que trop longtemps – IberoMedia
Oui, merci bemace. J'entrais les mauvais paramètres dans la partie arrière du module. – IberoMedia