Doctrine_Query::create() added for lazy folks
This commit is contained in:
parent
276af65256
commit
12a21ba50e
@ -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,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));
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -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"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user