RedBeanPHP\Repository::findCollection PHP Method

findCollection() public method

Finds a BeanCollection.
public findCollection ( string $type, string $sql, array $bindings = [] ) : redbeanphp\BeanCollection
$type string type of beans you are looking for
$sql string SQL to be used in query
$bindings array whether you prefer to use a WHERE clause or not (TRUE = not)
return redbeanphp\BeanCollection
    public function findCollection($type, $sql, $bindings = array())
    {
        try {
            $cursor = $this->writer->queryRecordWithCursor($type, $sql, $bindings);
            return new BeanCollection($type, $this, $cursor);
        } catch (SQLException $exception) {
            $this->handleException($exception);
        }
        return new BeanCollection($type, $this, new NullCursor());
    }

Usage Example

Example #1
0
 /**
  * Same as find() but returns a BeanCollection.
  *
  * @param string $type     type of beans you are looking for
  * @param string $addSQL   SQL to be used in query
  * @param array  $bindings a list of values to bind to query parameters
  *
  * @return array
  */
 public function findCollection($type, $sql = NULL, $bindings = array())
 {
     return $this->repository->findCollection($type, $sql, $bindings);
 }