【问题标题】:RedBean php count query with whereRedBean php计数查询与where
【发布时间】:2017-01-23 05:31:03
【问题描述】:

我需要在 redbean php 中使用 where 条件进行计数查询

我用过

R::count("company","country like 'United States'");

where country name 是 where 条件

请提出一些建议

【问题讨论】:

    标签: redbean


    【解决方案1】:

    Redbean 在第三个参数上需要一个数组,所以你应该使用:

    R::count("company", "country like ?", ["United States"]);

    请注意,每个? 都应该匹配数组中的一个元素,但是如果您有多个相同值的条件,您也可以使用一次:param,例如:

    R::count("company", "country like :name OR city like :name", [":name" => "United States"]);

    【讨论】:

      【解决方案2】:

      R::count("company","country like 'United States'");

      这很好用………… 但这不是
      R::count("company","country like '".$country."'");

      【讨论】:

      • 如何抛出错误?我认为你的引号很糟糕:'".$country."'"
      • 我认为你在 $country 3 个引号 ('") 之前,而你是 4 个引号 ("")。
      • 感谢@bluray 发现查询执行前的错误不在查询中
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-10
      • 2014-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多