Post by danijr » Tue Nov 21, 2017 3:13 am

hello, I have a code with which sorting products from a category, but I have some difficulty.

Here is the code itself: https://pastebin.com/VW1xcjY9

Code: Select all

Fatal error: Uncaught Exception: Error: 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 'FROM oc_product_to_category p2c LEFT JOIN oc_product p ON (p2c.product_id = p.pr' at line 1<br />Error No: 1064<br />SELECT cp.category_id AS category_id, c1.parent_id, c1.sort_order FROM oc_category_path cp LEFT JOIN oc_category c1 ON (cp.category_id = c1.category_id) LEFT JOIN oc_category c2 ON (cp.path_id = c2.category_id) LEFT JOIN oc_category_description cd1 ON (cp.path_id = cd1.category_id) LEFT JOIN oc_category_description cd2 ON (cp.category_id = cd2.category_id) LEFT JOIN oc_category_to_store c2s ON (c1.category_id = c2s.category_id) WHERE cp.path_id = '' AND cp.path_id != cp.category_id AND cd1.language_id = '1' AND cd2.language_id = '1' AND c1.status = 1 AND c2s.store_id = '0' FROM oc_product_to_category p2c LEFT JOIN oc_product p ON (p2c.product_id = p.product_id) LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) LE in 

Of course, the problem is here

Code: Select all


f (!empty($data['filter_category_id'])) {
			if (!empty($data['filter_sub_category'])) {
				$sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)";

			} else {
				$sql .= " FROM " . DB_PREFIX . "product_to_category p2c";
			}

			if (!empty($data['filter_filter'])) {
				$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)";
			} else {
				$sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)";
			}
		} else {
			$sql .= " FROM " . DB_PREFIX . "product p";
		}
If anyone can help?

New member

Posts

Joined
Fri Dec 02, 2016 10:28 pm

Post by MarketInSG » Tue Nov 21, 2017 11:16 pm

You cannot append the remaining SQL statement after the WHERE condition.


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore
Who is online

Users browsing this forum: No registered users and 74 guests