Create a new instance in a static function of an abstract class

Posted by arno on Stack Overflow See other posts from Stack Overflow or by arno
Published on 2010-05-20T12:09:08Z Indexed on 2010/05/20 12:10 UTC
Read the original article Hit count: 153

abstract class db_table {

    static function get_all_rows() {
        ...
        while(...) {
            $rows[] = new self();
            ...
        }
        return $rows;
    }
}

class user extends db_table {

}

$rows = user::get_all_rows();

I want to create instances of a class from a static method defined in the abstract parent class but PHP tells me "Fatal error: Cannot instantiate abstract class ..." How should I implement it correctly?

© Stack Overflow or respective owner

Related posts about php

Related posts about abstract-class