Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an ORM in a web application?

I recently got a reply from a server company asking if we are using an ORM in our application which does all the work of sifting application side (like Rails) or if we write reams of SQL, embedded functions etc which would make the database server do the processing for you.

Can anyone explain what is meant by this. Our web application is made up of PHP scripts with functions that make calls to the database to retrieve rows of data, then PHP processes these rows as needed to return results to the user.

thanks

like image 792
undefined Avatar asked Jan 21 '10 14:01

undefined


People also ask

What is an example of an ORM?

They usually look something like this: SELECT * FROM users WHERE email = '[email protected]'; Object-relational-mapping is the idea of being able to write queries like the one above, as well as much more complicated ones, using the object-oriented paradigm of your preferred programming language.

What is ORM and why is it used?

What is an ORM? An object-relational mapper provides an object-oriented layer between relational databases and object-oriented programming languages without having to write SQL queries. It standardizes interfaces reducing boilerplate and speeding development time.

What is ORM and types of ORM?

ORM stands for object-relational mapping, where objects are used to connect the programming language on to the database systems, with the facility to work SQL and object-oriented programming concepts.


1 Answers

It basically makes your database tables appear like objects on the PHP side of your site so you can easily manipulate data.

For example if you have a User table, getting this user's name is as easy as doing: $myUser->getName();

adding a new user in your database would be:

$myUser = new User();
$myUser->setName('John Doe');
$myUser->save();

Of course this is pseudo code (actually PHP Symfony/Doctrine code), but it's a simple example so you get the point.

like image 61
Guillaume Flandre Avatar answered Sep 21 '22 19:09

Guillaume Flandre