Commit 12a21ba5 authored by zYne's avatar zYne

Doctrine_Query::create() added for lazy folks

parent 276af652
......@@ -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
*
......
......@@ -2,13 +2,13 @@
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");
$this->hasColumn("email", "string", 200, array("email" => true));
// home_country should be a valid country code
$this->hasColumn("home_country", "string", 2, "country");
// home_country should be a valid country code and not null
$this->hasColumn("home_country", "string", 2, array("country" => true, "notnull" => true));
}
}
......
......@@ -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"),
);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment