Whenever you go with ORM (Object Relational Mapper) you will find DBAL (Database Abstraction Layer) side by side. So its necessary to know what these are, so as to get good insights of what you are using and whats the advantages that you will get.
DBAL (Database Abstraction Layer)
It acts as a layer between your code and database. Irrespective of whatever your database, the code written will work fine with minor tweaking.
Assume that for the current project your using MySQL once its a fully matured and gets huge traffic your team plan to switch the database to Oracle for some reason then the code you have written in MySQL must be rewritten to Oracle based queries. And rewriting the queries for the whole project is a tedious task.
Instead if you use any DBAL libraries then you can switch the configuration of the database and make sure your project will be up and running within a day (May be with some minor tweaking).
ORM (Object Relational Mapper)
Object Relational Mapping (ORM) is a technique (Design Pattern) of accessing a relational database from an object-oriented language.
If you have used any kind of frameworks like Symfony (if you come from PHP background)/Hibernate (Java), then your familiar with these. Its nothing but Entities.
In order to access the database in Object Oriented context and interface translating the object logic is necessary, this interface is called as ORM. Its make up of the object that give access to data and keep the business rules with themselves.
Eg.
class User{
private $email;
private $password;
public function setEmail($email){
$this->email = $email;
return $this;
}
public function getEmail(){
return $this->email;
}
public function setPassword($password){
$this->password = $password;
return $this;
}
public function getPassword(){
return $this->password;
}
}
/* To save User details you would do something like this */
$userObj = new User();
$userObj->setEmail('sanitizedEmail');
$userObj->setPassword('sanitizedPassword');
$userObj->save();
/* To fetch user details you would do something like this */
$userObj = new User();
$userDetails = $userObj->find($id);
Eg. Doctrine, Propel, RedBean