代码之家  ›  专栏  ›  技术社区  ›  Select0r

DBAL2.13$语句->execute()返回bool(而不是Result)

  •  0
  • Select0r  · 技术社区  · 5 年前

    自发布原则以来,DBAL2.13中已经添加了如下声明 here

    旧的获取结果的方法是这样的:

    $statement->execute();
    while (($row = $statement->fetch()) !== false) {
    }
    

    新方法是这样的:

    $result = $statement->execute();
    while (($row = $result->fetchAssociative()) !== false) {
    }
    

    $statement->execute() 不返回结果集,只返回一个布尔值,因此没有要迭代的内容,即使发行说明声明:

    DBAL3.0从语句API中提取所有fetch方法并移动 将它们转换为从语句::execute返回的新结果API。我们 已将此API向后移植到2.13

    0 回复  |  直到 5 年前
        1
  •  0
  •   Select0r    5 年前

    更新至条令/dbal 2.13.1(发布于2021年4月)并使用:

    $result = $statement->executeQuery();
    while (($row = $result->fetchAssociative()) !== false) {
    }
    

    推荐文章