Getting started - Setting table definition - Enum emulation.php 595 Bytes
Newer Older
1 2 3 4 5 6
<?php
class Article extends Doctrine_Record {
    public function setTableDefinition() {
        $this->hasColumn("title","string", 200);
        
        // maps to TINYINT on mysql
chtito's avatar
chtito committed
7
        $this->hasColumn("section", "enum", 2, array('values' => array("PHP","Python","Java","Ruby")));
8 9 10 11 12 13 14 15 16 17 18 19
    }
}
$article = new Article;
$article->title   = 'My first php article';
// doctrine auto-converts the section to integer when the 
// record is being saved
$article->section = 'PHP';
$article->save();

// on insert query with values 'My first php article' and 0 
// would be issued
?>