[pLog-svn] r1117 - in plog/trunk/class/dao: . customfields
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Thu Feb 17 21:35:46 GMT 2005
Author: oscar
Date: 2005-02-17 21:35:45 +0000 (Thu, 17 Feb 2005)
New Revision: 1117
Modified:
plog/trunk/class/dao/articlecomments.class.php
plog/trunk/class/dao/articles.class.php
plog/trunk/class/dao/blogs.class.php
plog/trunk/class/dao/customfields/customfield.class.php
plog/trunk/class/dao/customfields/customfields.class.php
plog/trunk/class/dao/trackback.class.php
plog/trunk/class/dao/trackbacks.class.php
plog/trunk/class/dao/users.class.php
Log:
fixed issue 255 (http://bugs.plogworld.net/view.php?id=255), where now Trackbacks::addTrackback() will take the parameter by reference so that we can modify it and fill in values such as the database id. I have made this change also for articles, comments, blogs and users.
Modified: plog/trunk/class/dao/articlecomments.class.php
===================================================================
--- plog/trunk/class/dao/articlecomments.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/articlecomments.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -37,8 +37,12 @@
/**
* Adds a comment to an article
+ *
+ * @param comment the UserComment object that we're going to add.
+ * @return Returns true if successful or false if error. Also in case of success, it will modify the UserComment
+ * object passed by reference and include its new id.
*/
- function addComment( $comment )
+ function addComment( &$comment )
{
$filter = new Textfilter();
$query = "INSERT INTO ".$this->getPrefix().
@@ -52,7 +56,13 @@
$result = $this->Execute( $query );
- return $result;
+ if( !$result )
+ return false;
+
+ // retrieve the last id and save it in the object
+ $comment->setId( $this->_db->Insert_ID());
+
+ return( true );
}
/**
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/articles.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -632,9 +632,10 @@
* Adds a new article to the database
*
* @param newArticle An Article object with all the necessary information.
- * @return Returns true if article was added successfully or false otherwise.
+ * @return Returns true if article was added successfully or false otherwise. If successful, it will modify the parmeter
+ * passed by reference and set its database id.
*/
- function addArticle( $newArticle )
+ function addArticle( &$newArticle )
{
// first, we build up the query
$filter = new Textfilter();
Modified: plog/trunk/class/dao/blogs.class.php
===================================================================
--- plog/trunk/class/dao/blogs.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/blogs.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -240,9 +240,10 @@
*
* @param blog A BlogInfo object with the necessary information
* @see BlogInfo
- * @return False if unsuccessful or true otherwise.
+ * @return False if unsuccessful or true otherwise. It will also set the database id of the
+ * parameter passed by reference in case it is successful.
*/
- function addBlog( $blog )
+ function addBlog( &$blog )
{
$blogSettings = $blog->getSettings();
if( !$blogSettings )
@@ -269,6 +270,8 @@
$blogId = $this->_db->Insert_ID();
+
+ $blog->setId( $blogId );
// create the row for the bayesian filter info
$bayesianFilterInfo = new BayesianFilterInfos();
Modified: plog/trunk/class/dao/customfields/customfield.class.php
===================================================================
--- plog/trunk/class/dao/customfields/customfield.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/customfields/customfield.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -45,6 +45,11 @@
return $this->_id;
}
+ function setId( $id )
+ {
+ $this->_id = $id;
+ }
+
function getName()
{
return $this->_name;
Modified: plog/trunk/class/dao/customfields/customfields.class.php
===================================================================
--- plog/trunk/class/dao/customfields/customfields.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/customfields/customfields.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -147,7 +147,7 @@
* @param field A CustomField object
* @return True if successful or false otherwise.
*/
- function addCustomField( $field )
+ function addCustomField( &$field )
{
if( $this->fieldExists( $field->getName(), $field->getBlogId()))
return false;
@@ -163,7 +163,11 @@
if( !$result )
return false;
- return $this->_db->Insert_ID();
+ $fieldId = $this->_db->Insert_ID();
+
+ $field->setId( $fieldId );
+
+ return( $fieldId );
}
/**
Modified: plog/trunk/class/dao/trackback.class.php
===================================================================
--- plog/trunk/class/dao/trackback.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/trackback.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -120,6 +120,16 @@
{
return $this->_id;
}
+
+ /**
+ * sets the id of the trackback
+ *
+ * @param id New database id of the object
+ */
+ function setId( $id )
+ {
+ $this->_id = $id;
+ }
/**
* Returns the Timestamp object corresponding to the SQL-like date. The Timestamp class offers
Modified: plog/trunk/class/dao/trackbacks.class.php
===================================================================
--- plog/trunk/class/dao/trackbacks.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/trackbacks.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -40,8 +40,10 @@
* Adds a trackback to the database.
*
* @param A Trackback object
+ * @return Returns true if successful or false otherwise. Also in case it is successful, it will modify
+ * the original object to include the id of the trackback that was added.
*/
- function addTrackback( $trackback )
+ function addTrackback( &$trackback )
{
$artId = $trackback->getArticleId();
$url = $trackback->getUrl();
@@ -60,8 +62,11 @@
if( !$result )
return false;
- else
- return true;
+
+ // set the trackback id
+ $trackback->setId( $this->_db->Insert_ID());
+
+ return true;
}
/**
Modified: plog/trunk/class/dao/users.class.php
===================================================================
--- plog/trunk/class/dao/users.class.php 2005-02-17 15:51:21 UTC (rev 1116)
+++ plog/trunk/class/dao/users.class.php 2005-02-17 21:35:45 UTC (rev 1117)
@@ -283,9 +283,10 @@
* Adds a user to the database.
*
* @param user An UserInfo object with the necessary information
- * @return Returns the identifier assigned to the user, or false if there was any error.
+ * @return Returns the identifier assigned to the user, or false if there was any error. It will also modify the
+ * UserInfo object passed by parameter and set its database id.
*/
- function addUser( $user )
+ function addUser( &$user )
{
$query = "INSERT INTO ".$this->getPrefix()."users(user,password,email,about,full_name,
resource_picture_id,properties,status)
@@ -302,6 +303,8 @@
return false;
$userId = $this->_db->Insert_ID();
+
+ $user->setId( $userId );
return $userId;
}
More information about the pLog-svn
mailing list