Originally Posted by
DrByte
Thank you DrByte. Following the instructions on that page I changed the code to:
PHP Code:
$test_sql = "SELECT SUM(op.products_quantity) * 12
FROM orders_products op
INNER JOIN orders o
ON o.orders_id = op.orders_id
AND o.orders_status = 2
INNER JOIN products_to_categories p2c
ON p2c.products_id = op.products_id
AND p2c.categories_id IN (81, 82)
INNER JOIN orders_products_attributes opa
ON opa.orders_products_id = op.orders_products_id
AND opa.products_options_values_id = 79";
global $db;
$test_sql = $db->bindVars($test_sql, ':lang_id', $_SESSION['languages_id'], 'integer');
$test_total = $db->Execute($test_sql);
Also tried this way:
PHP Code:
$test_sql2 = "SELECT SUM(op.products_quantity) * 40
FROM " . TABLE_ORDERS_PRODUCTS . " op
INNER JOIN orders o
ON o.orders_id = op.orders_id
AND o.orders_status = 2
INNER JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
ON p2c.products_id = op.products_id
AND p2c.categories_id IN (81, 82)
INNER JOIN " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa
ON opa.orders_products_id = op.orders_products_id
AND opa.products_options_values_id = 83";
global $db;
$test_sql2 = $db->bindVars($test_sql2, ':lang_id', $_SESSION['languages_id'], 'integer');
$test_total2 = $db->Execute($test_sql2);
Same error:
Catchable fatal error: Object of class queryFactoryResult could not be converted to string
Is the code wrong?
Bookmarks