这是调用构建RSS的函数的正确位置吗?它是一个reddit类型的网站。
function save() {
/*
Here we do either a create or
update operation depending
on the value of the id field.
Zero means create, non-zero
update
*/
if(!get_magic_quotes_gpc())
{
$this->title = addslashes($this->title);
$this->description = addslashes($this->description);
}
try
{
$db = parent::getConnection();
if($this->id == 0 )
{
$query = 'insert into articles (modified, username, url, title, description, points )';
$query .= " values ('$this->getModified()', '$this->username', '$this->url', '$this->title', '$this->description', $this->points)";
createRSS(); //**** rss function****
}
else if($this->id != 0)
{
$query = "update articles set modified = NOW()".", username = '$this->username', url = '$this->url', title = '".$this->title."', description = '".$this->description."', points = $this->points, ranking = $this->ranking where id = $this->id";
}
$lastid = parent::execSql2($query);
if($this->id == 0 )
$this->id = $lastid;
}
catch(Exception $e){
throw $e;
}
}
非常感谢
答案 0 :(得分:1)
可能不是。有时您可能希望在不更新RSS源的情况下保存文章对象 - 例如您可以在某个时候导入文章存档。因此,无论负责调用save(),都应该立即调用createRSS()本身。
e.g。
function createArticle($title, ...) {
$article->setTitle($title);
...
$article->save();
createRSS();
}