开发者

getTitle() in News.class.php in Symfony

开发者 https://www.devze.com 2023-03-29 03:41 出处:网络
i have table News: id| title| b开发者_如何学编程ody 1| title1 | body1 2| title2 | body2 etc. I have

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';
}
0

精彩评论

暂无评论...
验证码 换一张
取 消