Getting started - Setting table definition - Constraints and validators.php 522 Bytes
Newer Older
1 2 3 4
<?php
class User extends Doctrine_Record {
    public function setTableDefinition() {
        // the name cannot contain whitespace
5 6
        $this->hasColumn("name", "string", 50, array("nospace" => true));

7
        // the email should be a valid email
8 9 10 11 12
        $this->hasColumn("email", "string", 200, array("email" => true));

        // home_country should be a valid country code and not null
        $this->hasColumn("home_country", "string", 2, array("country" => true, "notnull" => true));

13 14 15
    }
}
?>