src/MVQN/Data/Models/Model.php
public static function select(): Collection
    {
        // Ensure the database is connected!
        $pdo = Database::connect();

        // Get the calling child class, ensuring that the Model class was not used!
        $class = self::getStaticChildClass();

        // Get the table name from either a @TableNameAnnotation or an automated conversion from the class name...
        $tableName = self::getTableName();

        // Build the SQL statement.
        $sql = "SELECT * FROM \"$tableName\"";

        // Fetch the results from the database.
        $results = $pdo->query($sql)->fetchAll();

        // Create a new Collection to store the converted objects.
        $collection = new Collection($class, []);

        // Loop through each result...
        foreach($results as $result)
        {
            // Create a new object and populate it's properties.
            $object = new $class($result);

            // Append the new object to the collection.
            $collection->push($object);
        }

        // Finally, return the Collection!
        return $collection;
    }
public static function select(): Collection
    {
        // Ensure the database is connected!
        $pdo = Database::connect();

        // Get the calling child class, ensuring that the Model class was not used!
        $class = self::getStaticChildClass();

        // Get the table name from either a @TableNameAnnotation or an automated conversion from the class name...
        $tableName = self::getTableName();

        // Build the SQL statement.
        $sql = "SELECT * FROM \"$tableName\"";

        // Fetch the results from the database.
        $results = $pdo->query($sql)->fetchAll();

        // Create a new Collection to store the converted objects.
        $collection = new Collection($class, []);

        // Loop through each result...
        foreach($results as $result)
        {
            // Create a new object and populate it's properties.
            $object = new $class($result);

            // Append the new object to the collection.
            $collection->push($object);
        }

        // Finally, return the Collection!
        return $collection;
    }
public static function select ( ) : Collection { // Ensure the database is connected! $ pdo = Database :: connect ( ) ; // Get the calling child class, ensuring that the Model class was not used! $ class = self :: getStaticChildClass ( ) ; // Get the table name from either a @TableNameAnnotation or an automated conversion from the class name... $ tableName = self :: getTableName ( ) ; // Build the SQL statement. $ sql = "SELECT * FROM \"$tableName\"" ; // Fetch the results from the database. $ results = $ pdo -> query ( $ sql ) -> fetchAll ( ) ; // Create a new Collection to store the converted objects. $ collection = new Collection ( $ class , [ ] ) ; // Loop through each result... foreach ( $ results as $ result ) { // Create a new object and populate it's properties. $ object = new $ class ( $ result ) ; // Append the new object to the collection. $ collection -> push ( $ object ) ; } // Finally, return the Collection! return $ collection ; }
Selects all rows from the database as a Collection of Model class objects.

@return Collection Returns a Collection of Model objects with populated data from the database.
@throws DatabaseConnectionException
@throws ModelClassException
@throws \ReflectionException
Selects all rows from the database as a Collection of Model class objects .