diff --git a/Doctrine/Query.php b/Doctrine/Query.php index ff2d21b70..2d43f62e2 100644 --- a/Doctrine/Query.php +++ b/Doctrine/Query.php @@ -39,6 +39,15 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { * @param boolean $limitSubqueryUsed */ private $limitSubqueryUsed = false; + /** + * create + * returns a new Doctrine_Query object + * + * @return Doctrine_Query + */ + public static function create() { + return new Doctrine_Query(); + } /** * count * diff --git a/manual/codes/Getting started - Setting table definition - Constraints and validators.php b/manual/codes/Getting started - Setting table definition - Constraints and validators.php index d7da54366..77e8b11b8 100644 --- a/manual/codes/Getting started - Setting table definition - Constraints and validators.php +++ b/manual/codes/Getting started - Setting table definition - Constraints and validators.php @@ -2,14 +2,14 @@ class User extends Doctrine_Record { public function setTableDefinition() { // the name cannot contain whitespace - $this->hasColumn("name", "string", 50, "nospace"); - + $this->hasColumn("name", "string", 50, array("nospace" => true)); + // the email should be a valid email - $this->hasColumn("email", "string", 200, "email"); - - // home_country should be a valid country code - $this->hasColumn("home_country", "string", 2, "country"); - + $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)); + } } ?> diff --git a/manual/codes/Getting started - Setting table definition - Introduction.php b/manual/codes/Getting started - Setting table definition - Introduction.php index 43e846f0c..42b68bf66 100644 --- a/manual/codes/Getting started - Setting table definition - Introduction.php +++ b/manual/codes/Getting started - Setting table definition - Introduction.php @@ -7,7 +7,26 @@ class Email extends Doctrine_Record { $this->hasColumn("address", // name of the column "string", // column type "200", // column length - "notblank|email" // validators / constraints + array("notblank" => true, + "email" => true // validators / constraints + ); + + + $this->hasColumn("address2", // name of the column + "string", // column type + "200", // column length + // validators / constraints without arguments can be + // specified also as as string with | separator + "notblank|email", + ); + + // Doctrine even supports the following format for + // validators / constraints which have no arguments: + + $this->hasColumn("address3", // name of the column + "string", // column type + "200", // column length + array("notblank", "email"), ); } }