Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6204241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:03:20+00:00 2026-05-24T05:03:20+00:00

I have some legacy DB with many tables (around 100) the old system is

  • 0

I have some legacy DB with many tables (around 100) the old system is run using php and have so many operation with data used in NLP.
I was a bit curious how thing could be done with Rails. I read that ActiveRecord is no good for legacy systems! but I sow some people used it with no problems, So why some clime that?
Also considering the following php code, with many If & SQL statements, some clime that such case is considered as typical data/database task not OO one, so it’s better to stay away from AcriveRecord or any other ORM. Is this true? if not, can it be done easily by Rails’s ActiveRecord?

Assuming all variables are submitted from a web form. we have some text to be annotate and we have to see if there’re any other users that agree with this user who submitted the form. Then we’ll update the agree table.

if ($submitted_id !=""){ 
$sql = "SELECT * FROM annotation WHERE relation_id = $relation_id";
$result = open_query($sql);
while ($row = mysql_fetch_assoc($result)) {
    $user_id = $row["user_id"];
    $line = "";
    $sql = "SELECT * FROM agree WHERE user_id = $user_id AND user_id_agree = $submitted_id LIMIT 1";
    $result = open_query($sql);
    $line = mysql_fetch_array($result, MYSQL_ASSOC);
    if ( $user_id != $submitted_id ) { 
        if ( $line == "" ) { 
            mysql_query ("INSERT INTO agree VALUES ('$user_id' , '$submitted_id', '1', CURRENT_TIMESTAMP)");
        } else { 
        $total = $line["total"];
        $new_total = $total+1;
        mysql_query ("UPDATE agree SET total = $new_total WHERE user_id = $user_id AND user_id_agree = $submitted_id LIMIT 1");
        }
    }
}
}

Regards

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:03:20+00:00Added an answer on May 24, 2026 at 5:03 am

    Well, using legacy database schemas with ActiveRecord makes you lose some of its advantages. For instance, Rails takes a “convention over configuration” approach to many things, and ActiveRecord inherits this. For instance, if you have a model called Product, Rails assumes your table will be called “products”. For this reason, you don’t have to configure the table name. The same holds through for foreign keys, URL conventions, etc. The more you are willing to make your application work the way Rails works, the easier a time you will have. If your goal going in is not “build an application that does X”, but rather “convert this application to Ruby and ActiveRecord”, the resulting code will not be as clear or idiomatic.

    If you try to write an application in the way that is conventional for the tool you are using, you will likely get clearer, more maintainable code as a result.

    As for the code you provided, it’s not entirely clear to me what it is supposed to do (since I do not have the context to know what “submitted_it”, “user_id_agree”, “annotation”, and so on mean in your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web-site that generates some simple tabular data as html tables, many
We have a huge (old legacy java) code-base, where many files (around 5k) have
I have some legacy code that was used to monitor my applications cpu,memory etc
I have some data (produced by a legacy application) that I know is invalid
I have some legacy data that was created on Windows XP. It contains absolute
I have some 10 year old Java code for calling a legacy SOAP authentication
Auto generating entities from a legacy database. Many of the tables have non standard
I have a table with some legacy data that I suspect may be a
We have some legacy ASP.NET code that detects if a request is secure, and
I have some legacy SQL (SP) declare @FactorCollectionId int; select @FactorCollectionId = collectionID from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.