diff --git a/manual/docs/Object relational mapping - Constraints and validators - Notnull.php b/manual/docs/Object relational mapping - Constraints and validators - Notnull.php new file mode 100644 index 000000000..57bb08f88 --- /dev/null +++ b/manual/docs/Object relational mapping - Constraints and validators - Notnull.php @@ -0,0 +1,19 @@ +A not-null constraint simply specifies that a column must not assume the null value. A not-null constraint is always written as a column constraint. + +The following definition uses a notnull constraint for column 'name'. This means that the specified column doesn't accept +null values. + + +class User extends Doctrine_Record +{ + public function setTableDefinition() + { + $this->hasColumn('name', 'string', 200, array('notnull' => true, + 'primary' => true)); + } +} + + +When this class gets exported to database the following Sql statement would get executed (in Mysql): + +CREATE TABLE user (name VARCHAR(200) NOT NULL, PRIMARY KEY(name))