getTitle() in News.class.php in Symfony
i have table News:
id | title | b开发者_如何学编程ody
1 | title1 | body1
2 | title2 | body2
etc.
I have
News.class.php and NewsTable.class.php
i would like edit method getTitle(). In News.class.php i add:
public function getTitle()
{
return $this->title . "aa"; //line 35
}
but i have error:
Notice: Undefined property: News::$title in localhost/new/lib/model/doctrine/News.class.php on line 35
i if change for:
public function getTitle()
{
return $this->getTitle() . "aa"; //line 35
}
then site not show.
if change:
public function getTitle()
{
return $this->body . "aa"; //line 35
}
this work OK! How can i fix?
Use $this->get('title')
. That gets the title from the Doctrine model class. :)
public function getTitle() {
return $this->get('title').'aa';
}
精彩评论