ajcarr1989 Posted November 24, 2010 Share Posted November 24, 2010 Ok so I have a post on a blog using an OO pattern to add to the blog. I'm stumped at how to even begin to do versioning. I want it to be able to record every version of the messages that is amended and then give the user the change to pick which article to use. Any ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/219679-oo-php-versioning/ Share on other sites More sharing options...
trq Posted November 24, 2010 Share Posted November 24, 2010 As the article is updated (you actually create a copy) store a date (or version) number. Quote Link to comment https://forums.phpfreaks.com/topic/219679-oo-php-versioning/#findComment-1138903 Share on other sites More sharing options...
ajcarr1989 Posted November 24, 2010 Author Share Posted November 24, 2010 thanks for the help. i kinda figured that but im unsurehow to do it in OO PHP. Obviously when you add to database you add a date. but my problem is when im editing at the moment it just adds as a new post. I need it to be able to add to the database, but update on the main screen, with some way of rolling back versions of the post. is there any tuts on this as i can't find anything anywhere. i'm stumped. Cheers again, very much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/219679-oo-php-versioning/#findComment-1138919 Share on other sites More sharing options...
ManiacDan Posted November 24, 2010 Share Posted November 24, 2010 OOP has nothing to do with your question, you seem to be getting caught up in your own design pattern. Take a step back and think about it: You have an object representing the article. It has changed. You want to record the changes in the database. What do you do? Add two columns to your table, for "edit date" and for "visible." When your system would otherwise do an UPDATE, change that so it simply sets the old record to "not visible" and INSERTS a new record with NOW() as the edit date. Now, you can simply display the visible record, and keep all the invisible ones as the edit history. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/219679-oo-php-versioning/#findComment-1138931 Share on other sites More sharing options...
ajcarr1989 Posted November 24, 2010 Author Share Posted November 24, 2010 Thanks for that. now i just need to work out how to write it! haha. this is for an assignment at uni. so thats why im confused. the blog at the moment adds and deletes with no issues. all i need now is for it to be able to edit a blog post and record previous versions of the edited posts. that will definetly help with the recording of the posts. now i just need to find out how to actually amend. iv got something called Command_BlogAdd.php and Command_BlogAddForm.php, views/addform.php and a Manager.php and ManagerMessage.php I'm guessing, the amend will be very similar to the add, just need it to show the message that was already there, in the text box to edit the article, that is where im struggling. the table is called messages and contains ID, TITLE, MESSAGE. I will add the EDIT DATE AND VISABLE columns as you said and see where i get with that. my last question is, how do i get the message title and message content to show in the addform screen to edit it. im guessing its something to do with calling the ID and displaying the title and message related to that ID in the form. Just don't know how to go about it :S again your help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/219679-oo-php-versioning/#findComment-1138968 Share on other sites More sharing options...
sudsy1970 Posted November 24, 2010 Share Posted November 24, 2010 very similiar to search i think static $get_message = "SELECT id,title,message FROM messages WHERE id = ?" ; function getOneMessage($id) { $values = array($id); $stmt = $this->doStatement(self::$get_message, $values); $result = $stmt->fetchAll(); return $result; } Quote Link to comment https://forums.phpfreaks.com/topic/219679-oo-php-versioning/#findComment-1138973 Share on other sites More sharing options...
ajcarr1989 Posted November 24, 2010 Author Share Posted November 24, 2010 is that you have got for the search? mines just a basic search, meant to be part of the pattern? i didn't know that! heh! Quote Link to comment https://forums.phpfreaks.com/topic/219679-oo-php-versioning/#findComment-1138975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.