Getting started - Setting table definition - Introduction.php 1.35 KB
Newer Older
doctrine's avatar
doctrine committed
1 2 3 4 5 6 7 8 9
<?php
class Email extends Doctrine_Record {
    public function setTableDefinition() {
        // setting custom table name:
        $this->setTableName('emails');

        $this->hasColumn("address",         // name of the column
                         "string",          // column type
                         "200",             // column length
10 11
                         array("notblank" => true,
                               "email"    => true  // validators / constraints
roger's avatar
roger committed
12 13 14
                               )
                         );

15 16 17 18

        $this->hasColumn("address2",         // name of the column
                         "string",          // column type
                         "200",             // column length
roger's avatar
roger committed
19
                         // validators / constraints without arguments can be
20
                         // specified also as as string with | separator
roger's avatar
roger committed
21
                         "notblank|email"
22
                         );
roger's avatar
roger committed
23 24

        // Doctrine even supports the following format for
25
        // validators / constraints which have no arguments:
roger's avatar
roger committed
26

27 28 29
        $this->hasColumn("address3",         // name of the column
                         "string",          // column type
                         "200",             // column length
roger's avatar
roger committed
30
                         array("notblank", "email")
doctrine's avatar
doctrine committed
31 32 33 34
                         );
    }
}
?>