You are currently reading the 1.2 documentation. Switch to 2.2  2.1  2.0 

Column Aliases

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();

Questions and Feedback

If you find a problem with the documentation or have a suggestion, please register and open a ticket.

If you need support or have a technical question, you can post to the user mailing-list.