DragonflyCMS Projects > MReviews > Import from Reviews Module > Community Forums > Phoenix Netology
Forum Index > Community > MReviews

Import from Reviews Module Reply to topic


Is there a way to bring my existing Reviews from the regular reviews module over to MReviews?

Also, we use ours for "trader feedbacks" much like ebay's system. It would be a lot better if the score at the top was an aggregate average, rather than just what the first user gave them. Any way to do this?

Please enter your server specs in your user profile! 😢


I'd have to review the tables but it is possible.

I can look at 'averaging' - will depend on how many db queries it adds to the system - it will probably be an extra field since the ratings are in different tables, and to preserve the original reviewer's rating.

btw, not an overnight exercise - need to find some time for it Smile

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Cool, well, do whatever you can. I am attaching the Reviews and Comments tables here for your perusal.
Attachment: cpg1_reviews.zip
Description
Filename cpg1_reviews.zip
Filesize 1.13 KiB
Downloaded 0 Time(s)
You are not allowed to view/download this attachment

Please enter your server specs in your user profile! 😢


How many reviews in your database?
MReviews uses categories and sub-categories, so these would have to be manually entered in the reviews and comments tables Sad

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


about 500 reviews, but all the same category. Would be nice if I could programatically put them all in the same category with one phpmyadmin command, or somehting like that.

I could even do it in excel if puch came to shove.

Please enter your server specs in your user profile! 😢


we can easily apply the same category/sub-category to the whole db through PMA with a couple of simple queries.

If you're familiar with PMA, you could also duplicate the existing Reviews tables via the "Operations" tab, thus eliminating any risk to your existing Reviews.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


I could probably muddle thru, but it wouldn't be pretty. I'm definitely an amature. Although I think I could handle copying pretty well.

EDIT: Done and done!

Please enter your server specs in your user profile! 😢


hmm, perhaps a special cpg_inst.php file might do the job seamlessly, and provide a sound basis for others wishing to changeover.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


That would be ideal =)

Please enter your server specs in your user profile! 😢


This is really basic, but it worked fine on a very small test database.
It doesn't affect your reviews database, but backup those tables anyway.
Copy the code below and create a file with some obscure name and place it in your root directory, then run it.
Please feedback results here.<?php ########################################################################## # File to convert an existing Reviews database to a NEW MReviews database # It is extremely basic. # Install the latest MReviews module, as new. # BACKUP your Reviews databases BEFORE doing anything else!!! # Give this file some obscure name and run it in your root directory. # Run this file ONCE - should be fine for small databases, say 500 or so. # DELETE this file when it's finished. # Check your MReviews database for the data. # Adjust Category and Sub-Category title through admin interface. # Delete any superfluous example categories etc. # Happy MReviewing Smile ########################################################################## include("includes/cmsinit.inc"); global $db, $prefix, $user_prefix; $result = $db->sql_query('SELECT * FROM '.$prefix.'_reviews', true); if ($db->sql_numrows($result) > 0) { while ($row = $db->sql_fetchrow($result)) { $db->sql_query("INSERT INTO ".$prefix."_MReviews SET rid='$row[id]', cid='1', scid='1', date='$row[date]', author='".Fix_Quotes($row['reviewer'])."', author_email='".Fix_Quotes($row['email'])."', author_user='0', author_ip='0', pagename='".Fix_Quotes($row['title'])."', content='".Fix_Quotes($row['text'])."', cover='".Fix_Quotes($row['cover'])."', r_link='".Fix_Quotes($row['url'])."', r_link_title='".Fix_Quotes($row['url_title'])."', score='$row[score]', counter='$row[hits]'"); } } $db->sql_freeresult($result); $result2 = $db->sql_query("SELECT u.username, m.author FROM ".$user_prefix."_users AS u INNER JOIN ".$prefix."_MReviews AS m ON ( u.username = m.author)"); while (list($uname) = $db->sql_fetchrow($result2, SQL_NUM)) { $db->sql_query("UPDATE ".$prefix."_MReviews SET author_user='1' WHERE author='".$uname."'"); } $db->sql_freeresult($result2); $result3 = $db->sql_query('SELECT * FROM '.$prefix.'_reviews_comments', true); if ($db->sql_numrows($result3) > 0) { while ($row3 = $db->sql_fetchrow($result3)) { $db->sql_query("INSERT INTO ".$prefix."_MReviews_comments SET rid='$row3[rid]', userid='".Fix_Quotes($row3['userid'])."', userip='0', com_id='$row3[cid]', date='$row3[date]', comments='".Fix_Quotes($row3['comments'])."', score='$row3[score]'"); } } $db->sql_freeresult($result3); echo "Finished converting Reviews to MReviews - please delete this file"; ?>

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):

All times are Australia/Adelaide


Jump to: