Skip to content

Instantly share code, notes, and snippets.

@craigw
Forked from sneeu/models.php
Created October 14, 2009 11:13
Show Gist options
  • Save craigw/209987 to your computer and use it in GitHub Desktop.
Save craigw/209987 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