views:

183

answers:

7

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

+3  A: 

It is an Object Relational Mapping. See link to wikipedia below.

http://en.wikipedia.org/wiki/Object-relational_mapping

Adam Carr
Usually it's a "mapping," not a "mapper." Note the Wikipedia redirect.
Matt Ball
Updated to reflect Bears' comment above from mapper to mapping.
Adam Carr
A: 

ORM is Object Relational Mapper. which maps the java objects to the database tables and lets you perform some database transactions thorough your code. EX of ORM tools are like Hibernate, Ibatis ..

GK
A: 

ORM is used for Mapping your database objects to your application objects.

In a simple application using ORM, you should have functions that gets/sets data from/to DB should return appropriate application object/objects.

Aykut
+1  A: 

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.

Guillaume Flandre
A: 

An ORM is an abstraction that is supposed to simplify working with a relational database in an object oriented language. It's basically a set of classes and methods that let you create, retrieve and update data without using SQL directly.

For instance instead of writing $result=mysql_query('select * from sandwiches where color='green' and size='2');

you can use an interface like $result=$sandwiches->get('color'=>'green',=>'size'=>'2');

and the ORM turns this into SQL and executes the query, taking care of joins, etc.

Popular PHP ORMs are Doctrine and Propel

If you don't know whether you're using one, than it's pretty unlikely that you are!

Alex JL
A: 

ORM is a Wikipedia article on Object Relational mapping.

Andrew Noyes
A: 

Object Relational Mapping is an easy way of mapping Database objects ( tables, views ... ) to classes/objects in OOPL. Hibernate and NHibernate are a few examples of ORM. it does all the tedious task of handling and mapping result sets..

Raj