Search code examples
redbean

RedBean php count query with where


I need a count query in redbean php with where condision

I used

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

where country name is the where condision

plz suggest some thing


Solution

  • Redbean expects an array on 3rd parameter, so you should use:

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

    note that every ? should match one element in array, but if you have more conditions for the same value, you can also use :param once instead, for ex:

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