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='niinatar'' at line 1 (42000)

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