Php 这是调用RSS构建功能的正确位置吗?

Php 这是调用RSS构建功能的正确位置吗?,php,mysql,html,rss,function,Php,Mysql,Html,Rss,Function,这是调用构建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 */

这是调用构建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;
        }
    }

非常感谢

可能不会。有时,您可能希望在不更新RSS提要的情况下保存文章对象,例如,您可能会在某个时候导入文章存档。因此,负责调用save()的任何人都应该在之后立即调用createRSS()本身

e、 g


这个问题目前无法回答。你发布的代码几乎没有说明你的应用程序是如何工作的。
function createArticle($title, ...) {
  $article->setTitle($title);
  ...
  $article->save();
  createRSS();
}