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

  • SEARCH
  • Home
  • 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 242841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:52:17+00:00 2026-05-11T20:52:17+00:00

Ok, so everyone has decided (and for good reason) strait SQL is of the

  • 0

Ok, so everyone has decided (and for good reason) strait SQL is of the devil. This leaves us with many methods of placing a “middle-man” in our code to separate our code from the database. I am now going to spit out all the info I have gathered in the hope someone can set me strait and tell me what I built.

An ORM (Object-relational mapping) is a series of tools (loosely or tightly integrated depends) which maps database rows to objects in the application.

In an AR (Active-Record) is a type of ORM in which a database table or view is wrapped into a class, thus an object instance is tied to a single row in the table.

Data mapping (DM) is a type of ORM that is the process of creating data element mappings between two distinct data models.

All three claim to work like this:

$user = new User();
$user->name = 'Fred';
$user->save();

Usually with a User class something like this:

class User extends Model {
    // Specify the database table
    protected $table = "users";

    // Define your fields
    protected $fields = array(
        'id' => array('type' => 'int', 'primary' => true),
        'name' => array('type' => 'string', 'required' => true),
        'email' => array('type' => 'text', 'required' => true)
    );
}

With this setup you can easily fetch rows without the need to write SQL.

// users
$users = $user->fetch(array('id' => 3));

Some AR classes actually look more like this:

$db->where('id' => 3);
$db->join('posts', 'posts.user_id = users.id');
$results = $db->get('users');

Ok, now this is where it gets hairy. Everyone and his brother seems to have a different view on what type of code falls where. While most agree that an AR or DM is a type of ORM – but sometimes the lines that tell AR’s from DM’s seem to smear.

I wrote a class that uses a single object ($db) in which you make calls to this object and it handles SQL creation for result saving/fetching.

//Fetch the users
$results = $db->select('id, name')->where('id > 4')->get('users');

//Set them active
while($user = $results->fetch()) {
    $user->active = TRUE;
    $user->save();
}

So the question is “what is it?”, and why don’t people agree on these terms?

  • 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-11T20:52:17+00:00Added an answer on May 11, 2026 at 8:52 pm

    You might as well make up the acronyms ORM, RM DM whatever … it is all just state transferred from one medium to another and wrapped in function/semantics.

    Sun Microsystems and Microsoft do it all the time with Java and C#. Let’s take something simple and give it a new name! What a great idea.

    If you say ORM .. everyone knows what it is, in its many guises. Your code looks like the Linq stuff though.

    No magic, but alot of buzzwords and fuss IMHO.

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

Sidebar

Related Questions

Everyone has this huge massively parallelized supercomputer on their desktop in the form of
At my work everyone has sql snippets that they use to answer questions. Some
My IT department has decided to spam everyone with annoying notifications. It seems like
Just about everyone has ran into this specific issue: function addLinks () { for
It seems like everyone has found this without trouble. I do not see an
Seems like everyone has there own story when it comes to this so here
Everyone has accidentally forgotten the WHERE clause on a DELETE query and blasted some
I have a page which requires use of non-default fonts, and not everyone has
Everyone (at least everyone who uses a compiled language) has faced compilation errors but
HI everyone, Just looking for a website or pdf reference which has a color

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.