Это правильное место для вызова функции построения RSS? - PullRequest
0 голосов
/ 15 мая 2009

Это правильное место для вызова функции, которая создает 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;
        }
    }

Большое спасибо

1 Ответ

1 голос
/ 15 мая 2009

Наверное, нет. Могут быть случаи, когда вы хотите сохранить объект статьи без обновления вашего RSS-канала - например, Вы можете импортировать архив статей в какой-то момент. Таким образом, все, что отвечает за вызов save (), должно вызывать непосредственно сам createRSS ().

, например

function createArticle($title, ...) {
  $article->setTitle($title);
  ...
  $article->save();
  createRSS();
}
...