Doctrine offers a way of setting column aliases. This can be very useful when you want to keep the application logic separate from the database logic. For example if you want to change the name of the database field all you need to change at your application is the column definition.
// models/Book.php
class Book extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('bookTitle as title', 'string');
}
}
Here is the same example in YAML format. You can read more about YAML in the YAML Schema Files chapter:
---
# schema.yml
# ...
Book:
columns:
bookTitle:
name: bookTitle as title
type: string
Now the column in the database is named bookTitle but you can access the property on your objects using title.
// test.php
// ...
$book = new Book();
$book->title = 'Some book';
$book->save();