Sunday, 11 August 2013

PHP objet oriented access to a method and issues with $this

PHP objet oriented access to a method and issues with $this

I have been working with Yii framework for a while, but know I am trying
to work on my own minimalistic framework based on MVC architecture. Let's
just say that I have a parent model ModelCore which extends all other
models (mentioned PageModel also). It has defined method:
public function find( $condition ){
$sql = "SELECT * FROM {$this->table()} WHERE {$condition} LIMIT 1";
// executing query and returning the result
}
And I am stuck at the point when I want to call this method from other
class (URLresolver) this way:
//...
elseif ( PageModel::find("`url` = '{$bit}'") != NULL ) {
//...
The scripts ends with fatal error: Call to undefined method
URLresolver::table()
If someone can explain me how theese things work in PHP and how can I
easily access a method I would be grateful.
Thanks a lot.

No comments:

Post a Comment