Db :: getInstance()-> insert()没有显示错误,不起作用

时间:2019-09-25 19:20:38

标签: prestashop

我正在将数据插入数据库。它不会被插入。如果我通过原始SQL进行同样的操作,那么它将起作用。也不会显示任何错误。

<h1>Games</h1>
<div>
  <div>
    <h2>
      <script>
        games[0].title
      </script>
    </h2>
    <button>Buy</button>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

尝试替换:

$is_allowed = (bool) Db::getInstance()->execute("SELECT available_for_order FROM ps_product WHERE id_product=".$id_product); // is product availabe for order when stock is null or zero.

作者

$is_allowed = (bool) Db::getInstance()->getValue("SELECT available_for_order FROM ps_product WHERE id_product=".$id_product); // is product availabe for order when stock is null or zero. 

execute()将返回truefalse(如果请求已正确执行,但请求结果未正确执行)。 getValue() 返回您请求的结果。

还有getRow()可以获取同一行的多个元素,还有executeS()可以获取多行。

致谢