当我尝试创建自定义sql时,我遇到了同样的问题。我的Prestashop版本1.7.3.4
$sql_order_detail = 'SELECT `id_order_detail`, `product_id`, `product_quantity`, `unit_price_tax_incl` FROM '._DB_PREFIX_.'order_detail WHERE `id_order` = ' . $id_order;
$order_details = Db::getInstance()->ExecuteS($this->sql_order_detail, $array = true, $use_cache = 0);
我通过日志和phpMyAdmin测试我的sql:
SELECT `id_order_detail`, `product_id`, `product_quantity`, `unit_price_tax_incl` FROM ps_order_detail WHERE `id_order` = 24
错误是:
stderr: Db->executeS() must be used only with select, show, explain or describe queries,
答案 0 :(得分:0)
使用以下方法解决: (神秘地)
$sql = new DbQuery();
$sql->select('*');
$sql->from('order_detail');
$sql->where('id_order = ' . $id_order);
$order_details = Db::getInstance()->executeS($sql);