src/MVQN/Data/Models/Model.php
public static function where(string $column, string $operator, $value): 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();

        // Lookup the correct column name.
        $column = self::getColumnName($column);

        // IF no matching column name could be determined, THEN throw an Exception!
        if($column === null)
            throw new ModelMissingPropertyException("Could not find a property '$column' of class '$class'.  ".
                "Are you missing a '@ColumnNameAnnotation' on a property?");

        // Build the SQL statement.
        $sql = "SELECT * FROM \"$tableName\" WHERE \"$column\" $operator ".
            (gettype($value) === "string" ? "'$value'" : "$value");

        // 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 where(string $column, string $operator, $value): 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();

        // Lookup the correct column name.
        $column = self::getColumnName($column);

        // IF no matching column name could be determined, THEN throw an Exception!
        if($column === null)
            throw new ModelMissingPropertyException("Could not find a property '$column' of class '$class'.  ".
                "Are you missing a '@ColumnNameAnnotation' on a property?");

        // Build the SQL statement.
        $sql = "SELECT * FROM \"$tableName\" WHERE \"$column\" $operator ".
            (gettype($value) === "string" ? "'$value'" : "$value");

        // 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 where ( string $ column , string $ operator , $ value ) : 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 ( ) ; // Lookup the correct column name. $ column = self :: getColumnName ( $ column ) ; // IF no matching column name could be determined, THEN throw an Exception! if ( $ column === null ) throw new ModelMissingPropertyException ( "Could not find a property '$column' of class '$class'.  " . "Are you missing a '@ColumnNameAnnotation' on a property?" ) ; // Build the SQL statement. $ sql = "SELECT * FROM \"$tableName\" WHERE \"$column\" $operator " . ( gettype ( $ value ) === "string" ? "'$value'" : "$value" ) ; // 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 only the matching rows from the database as a Collection of Model class objects.

@param string $column The column name on which to compare.
@param string $operator The operator to use for comparison.
@param mixed $value The value on which to compare.
@return Collection Returns a Collection of Model objects with populated data from the database.
@throws DatabaseConnectionException
@throws ModelClassException
@throws ModelMissingPropertyException
@throws \ReflectionException
Selects only the matching rows from the database as a Collection of Model class objects .