Is this a good place to call the RSS build function?
Is this a good place to call the function that creates the RSS? its for a site like 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;
}
}
Thank you very much
-2
a source to share
1 answer
Probably not. There may be times when you want to save the article object without refreshing your rss feed - for example. you can import an archive of articles at some point. As such, whatever is responsible for calling save () must immediately call createRSS ().
eg.
function createArticle($title, ...) {
$article->setTitle($title);
...
$article->save();
createRSS();
}
+1
a source to share