Error 1064 - Forum | JoomShaper
Staff replied SP Page Builder

Error 1064

Asked by ASG - Anerkannte Schulgesellschaft mbH 1 year ago Last activity 1 year ago

Hello,

after updating SP Page Builder 4 to the latest version 5.6.1, the following SGL error occurs in the frontend.

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 '8) ORDER BY lft ASC' at line 3

Please solve the problem quickly.

Best regards

3 replies

Ziaul Kabir Staff

Hello,

Thanks for raeching out to us.

Please, check now, Your issues is resolved.

Thanks

ASG - Anerkannte Schulgesellschaft mbH Asked this

Ok, thank you. And what was the error? Just in case it happens again.

Ziaul Kabir Staff

There was query related issues when comes empty or null value in here

JROOT/components/com_sppagebuilder/helpers/articles.php:407

Fixed Code:

public static function getCategories($parent_id = [1], $include_subcategories = true, $child = false, $cats = array()) {

    $app = Factory::getApplication();
    $db = Factory::getDbo();
    $query = $db->getQuery(true);

    $query
        ->select('*')
        ->from($db->quoteName('#__categories'))
        ->where($db->quoteName('extension') . ' = ' . $db->quote('com_content'))
        ->where($db->quoteName('published') . ' = ' . $db->quote(1))
        ->where($db->quoteName('access') . " IN (" . implode(',', Factory::getUser()->getAuthorisedViewLevels()) . ")")
        ->where($db->quoteName('language') . " IN (" . $db->Quote(Factory::getLanguage()->getTag()) . ", " . $db->Quote('*') . ")");

    // Sanitize and check parent IDs
    $filteredIds = array_filter(array_map('intval', $parent_id));

    if (!empty($filteredIds)) {
        $query->where($db->quoteName('parent_id') . " IN (" . implode(',', $filteredIds) . ")");
    }

    $query->order($db->quoteName('lft') . ' ASC');

    $db->setQuery($query);
    $rows = $db->loadObjectList();

    foreach ($rows as $row) {
        if ($include_subcategories) {
            $cats[] = $row->id;
            if (self::hasChildren($row->id)) {
                $cats = self::getCategories([$row->id], $include_subcategories, true, $cats);
            }
        }
    }

    return $cats;
}
Log in to reply.