Skip to content

Instantly share code, notes, and snippets.

@sneeu
Created October 14, 2009 10:43
Show Gist options
  • Save sneeu/209971 to your computer and use it in GitHub Desktop.
Save sneeu/209971 to your computer and use it in GitHub Desktop.
<?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