500 Internal Server Error

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND i.permalink='heidi-tuisku'' at line 1 (42000)

#0 /var/www/html/CM/Database/CSql.php(168): PDO->query()
#1 /var/www/html/sites/tuotekone/includes/functions.php(99): CM\Database\CSql->getAssocArray()
#2 /var/www/html/sites/tuotekone/controllers/ItemController.php(236): getWDItemWithPermalink()
#3 [internal function]: ItemController::viewItemPath2Permalink()
#4 /var/www/html/CM/Core/Dispatcher.php(146): call_user_func_array()
#5 /var/www/html/CM/Core/Dispatcher.php(126): CM\Core\Dispatcher->invokeMethod()
#6 /var/www/html/CM/Net/Router.php(115): CM\Core\Dispatcher->execute()
#7 /var/www/html/CM/Engine.php(315): CM\Net\Router->route()
#8 [internal function]: CM\Engine->_start()
#9 /var/www/html/CM/Core/Dispatcher.php(143): call_user_func_array()
#10 /var/www/html/CM/Core/Dispatcher.php(126): CM\Core\Dispatcher->invokeMethod()
#11 /var/www/html/CM/Core/Dispatcher.php(52): CM\Core\Dispatcher->execute()
#12 /var/www/html/CM/Engine.php(119): CM\Core\Dispatcher->run()
#13 /var/www/html/CM/CM.php(66): CM\Engine->__call()
#14 /var/www/html/sites/tuotekone/index.php(6): CM::__callStatic()
#15 {main}