Created
October 14, 2009 10:43
-
-
Save sneeu/209971 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Model { | |
static abstract function getFields(); | |
static function getFieldsForSQL() { | |
return implode(', ', self::getFields()); | |
} | |
static function getAll() { | |
return 'SELECT ' . self::getFieldsForSQL() . ' FROM ...'; | |
} | |
} | |
class User extends Model { | |
static function getFields() { | |
return array('username', 'password'); | |
} | |
} | |
print User::getAll(); | |
// Error is: | |
// Fatal error: Cannot call abstract method Model::getFields() in ...models.php on line 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment