entity.php
public static function find($where = '', $orderbyfield = null, $count = -1, $offset = -1)
    {

        $class = get_called_class();
        $meta = $class::getMetadata();
        $table = isset($meta['view']) ? $meta['view'] : $meta['table'];
        $conn = DB::getConnect();
        $list = array();
        $sql = "select * from " . $table;

        if (strlen(trim($where)) > 0) {
            $sql .= " where " . $where;
        }

        if (strlen(trim($orderbyfield)) > 0) {
            $sql .= " order by " . $orderbyfield;

        }

        if ($offset >= 0 or $count >= 0) {
            $rs = $conn->SelectLimit($sql, $count, $offset);
        } else {
            $rs = $conn->Execute($sql);
        }

        foreach ($rs as $row) {
            $list[$row[$meta['keyfield']]] = new $class($row);
            $list[$row[$meta['keyfield']]]->afterLoad();
        }
        return $list;
    }
public static function find($where = '', $orderbyfield = null, $count = -1, $offset = -1)
    {

        $class = get_called_class();
        $meta = $class::getMetadata();
        $table = isset($meta['view']) ? $meta['view'] : $meta['table'];
        $conn = DB::getConnect();
        $list = array();
        $sql = "select * from " . $table;

        if (strlen(trim($where)) > 0) {
            $sql .= " where " . $where;
        }

        if (strlen(trim($orderbyfield)) > 0) {
            $sql .= " order by " . $orderbyfield;

        }

        if ($offset >= 0 or $count >= 0) {
            $rs = $conn->SelectLimit($sql, $count, $offset);
        } else {
            $rs = $conn->Execute($sql);
        }

        foreach ($rs as $row) {
            $list[$row[$meta['keyfield']]] = new $class($row);
            $list[$row[$meta['keyfield']]]->afterLoad();
        }
        return $list;
    }
Возвращает  массив  сущностей  из  БД  по  критерию

@param mixed $where Условие  для предиката where
@param mixed $orderbyfield
@param mixed $orderbydir
@param mixed $count
@param mixed $offset