好的,所以我有一个问题,我需要将一组产品 ID 传递给下面的 sql 语句
$index = 0;
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$prod = $products[$index]['id'];
if (strpos($prod,"{")){
$product = preg_split("^[{}]^",$prod);
}else{
$product = $prod;
}
}
$product_query = tep_db_query("select cb.products_id, SUM(cb.customers_basket_quantity),SUM(p.products_rate) from " . TABLE_PRODUCTS . " p INNER JOIN " . TABLE_CUSTOMERS_BASKET . " cb ON p.products_id = cb.products_id
WHERE cb.customers_id ='" . $customer_id ."'
AND p.products_id IN '".$product ."'
");
结果总是
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Array'' at line 3
select cb.products_id, SUM(cb.customers_basket_quantity),SUM(p.products_rate) from products p INNER JOIN customers_basket cb ON p.products_id = cb.products_id WHERE cb.customers_id ='3' AND p.products_id IN 'Array'