在执行操作时,Db :: getInstance()-> ExecuteS错误“必须仅与select一起使用”

时间:2018-07-23 09:43:23

标签: database prestashop-1.7

当我尝试创建自定义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,

1 个答案:

答案 0 :(得分:0)

使用以下方法解决: (神秘地)

$sql = new DbQuery();
$sql->select('*');
$sql->from('order_detail');
$sql->where('id_order = ' . $id_order);
$order_details = Db::getInstance()->executeS($sql);