public static function count($filter = []): int
    {
        /* @var $class LightModel */
        $className = get_called_class();
        $class = new $className;
        $tableKey = $class->getKeyName();

        $sql = 'SELECT COUNT(' . $tableKey . ') FROM ' . $class->getTableName() . ' WHERE 1=1';
        $params = self::handleFilter($sql, $filter, $class);

        $query = DB::getConnection()->prepare($sql);
        $query->execute($params);

        return (int) $query->fetchColumn(0);
    }
public static function count($filter = []): int
    {
        /* @var $class LightModel */
        $className = get_called_class();
        $class = new $className;
        $tableKey = $class->getKeyName();

        $sql = 'SELECT COUNT(' . $tableKey . ') FROM ' . $class->getTableName() . ' WHERE 1=1';
        $params = self::handleFilter($sql, $filter, $class);

        $query = DB::getConnection()->prepare($sql);
        $query->execute($params);

        return (int) $query->fetchColumn(0);
    }
public static function count ( $ filter = [ ] ) : int { /* @var $class LightModel */ $ className = get_called_class ( ) ; $ class = new $ className ; $ tableKey = $ class -> getKeyName ( ) ; $ sql = 'SELECT COUNT(' . $ tableKey . ') FROM ' . $ class -> getTableName ( ) . ' WHERE 1=1' ; $ params = self :: handleFilter ( $ sql , $ filter , $ class ) ; $ query = DB :: getConnection ( ) -> prepare ( $ sql ) ; $ query -> execute ( $ params ) ; return ( int ) $ query -> fetchColumn ( 0 ) ; }
Count items based on filter

@param array $filter
@return int
Count items based on filter