VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: n3t on October 21, 2016, 00:28:17 AM

Title: Invaild SQL
Post by: n3t on October 21, 2016, 00:28:17 AM
Hi,

on my multilanguage eshop (VM 3.0.18, Joomla 3.6.2), if language is not the defaut one I meet this SQL error:

/administrator/components/com_virtuemart/plugins/vmpsplugin.php:528

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 'WHERE i.`published` = "1" AND j.`element` = "..."

It is caused bo code on line 492

$useJLback = false;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){
$joins[] = ' LEFT JOIN `#__virtuemart_'.$this->_psType.'_'.VmConfig::$jDefLang.'` as ljd';
$useJLback = true;
}

which IMO should be

$useJLback = false;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){
$joins[] = ' LEFT JOIN `#__virtuemart_'.$this->_psType.'methods_'.VmConfig::$jDefLang.'` as ljd using (`virtuemart_'.$this->_psType.'method_id`)';
$useJLback = true;
}

Seems like the code is unfinished.
Title: Re: Invaild SQL
Post by: n3t on October 21, 2016, 00:34:05 AM
I forgot: MySQL 5.6.21
Title: Re: Invaild SQL
Post by: n3t on October 21, 2016, 00:42:00 AM
Same situation in /administrator/components/com_virtuemart/models/shipmentmethod.php line 130

$useJLback = false;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){
$joins .= ' LEFT JOIN `#__virtuemart_shipmentmethods_'.VmConfig::$jDefLang.'` as ljd';
$useJLback = true;
}

should be

$useJLback = false;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){
$joins .= ' LEFT JOIN `#__virtuemart_shipmentmethods_'.VmConfig::$jDefLang.'` as ljd using (`virtuemart_shipmentmethod_id`)';
$useJLback = true;
}


and also in /administrator/components/com_virtuemart/models/paymentmethod.php line 130


$useJLback = false;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){
$joins .= ' LEFT JOIN `#__virtuemart_paymentmethods_'.VmConfig::$jDefLang.'` as ljd';
$useJLback = true;
}

should be

$useJLback = false;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){
$joins .= ' LEFT JOIN `#__virtuemart_paymentmethods_'.VmConfig::$jDefLang.'` as ljd using (`virtuemart_paymentmethod_id`)';
$useJLback = true;
}