[pLog-svn] r2000 - plog/branches/plog-1.0.1/class/dao
jondaley at devel.plogworld.net
jondaley at devel.plogworld.net
Fri May 13 04:12:05 GMT 2005
Author: jondaley
Date: 2005-05-13 04:12:04 +0000 (Fri, 13 May 2005)
New Revision: 2000
Modified:
plog/branches/plog-1.0.1/class/dao/articles.class.php
Log:
added method to get an article id given a slug. useful for saving referrers when caching is enabled
Modified: plog/branches/plog-1.0.1/class/dao/articles.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/dao/articles.class.php 2005-05-13 02:35:31 UTC (rev 1999)
+++ plog/branches/plog-1.0.1/class/dao/articles.class.php 2005-05-13 04:12:04 UTC (rev 2000)
@@ -429,6 +429,27 @@
return $fullarticles;
}
+
+ /**
+ * Takes an article name and returns the id
+ * @param articleName an article "name" (the post 'slug')
+ * @return articleId or 0 if unsuccessful
+ */
+ function getArticleIdFromName($articleName){
+ // we have to build up the query, which will be pretty long...
+ $query = "SELECT id FROM ".$this->getPrefix()."articles ".
+ " WHERE slug = '".Db::qstr($articleName)."'";
+
+ $result = $this->Execute($query);
+
+ if($row = $result->FetchRow()){
+ if($row["id"])
+ return $row["id"];
+ }
+ return 0;
+ }
+
+
/**
* returns the text of a bunch of articles, given their ids
More information about the pLog-svn
mailing list