1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Docs updated

This commit is contained in:
zYne 2006-08-21 10:16:36 +00:00
parent f44cc73215
commit 45bca0358a
6 changed files with 50 additions and 10 deletions

View File

@ -226,7 +226,9 @@ class Doctrine_Validator {
$looseType = self::gettype($var);
if($type == 'enum')
$type = 'integer';
$type = 'integer';
elseif($type == 'date' || $type == 'clob')
$type = 'string';
switch($looseType):
case 'float':

View File

@ -8,7 +8,14 @@ class Doctrine_Validator_Date {
* @return boolean
*/
public function validate(Doctrine_Record $record, $key, $value, $args) {
return checkdate($value);
if(empty($value))
return true;
$e = explode("-", $value);
if(count($e) !== 3)
return false;
return checkdate($e[1], $e[0], $e[2]);
}
}
?>

View File

@ -5,18 +5,22 @@ class Entity extends Doctrine_Record {
$this->hasColumn("username","string",20);
$this->hasColumn("password","string",16);
$this->hasColumn("created","integer",11);
// this column is used for column
// aggregation inheritance
$this->hasColumn("type", "integer", 11);
}
}
class User extends Entity {
public function setUp() {
$this->setInheritanceMap(array("type"=>1);
$this->setInheritanceMap(array("type"=>1));
}
}
class Group extends Entity {
public function setUp() {
$this->setInheritanceMap(array("type"=>2);
$this->setInheritanceMap(array("type"=>2));
}
}
?>

View File

@ -35,6 +35,10 @@ $user->Group[1]->name = "Second Group";
// save changes into database
$user->save();
// deleting the associations between user and groups it belongs to
$user->Groupuser->delete();
$groups = new Doctrine_Collection($session->getTable("Group"));
$groups[0]->name = "Third Group";
@ -46,4 +50,5 @@ $user->Group[2] = $groups[0];
$user->Group = $groups;
// $user will now have two groups 'Third Group' and 'Fourth Group'
?>

View File

@ -1,5 +1,14 @@
If you are coming from relational database background it may be familiar to you
how many-to-many associations are handled: an additional association table is needed.
<br \><br \>
In many-to-many relations the relation between the two components is always an aggregate
relation and the association table is owned by both ends. For example in the case of users and groups
when user is being deleted the groups it belongs to are not being deleted and the associations between this user
and the groups it belongs to are being deleted.
<br \><br \>
Sometimes you may not want that association table rows are being deleted when user / group is being deleted. You can override
this behoviour by setting the relations to association component (in this case Groupuser) explicitly.
<br \><br \>
In the following example we have Groups and Users of which relation is defined as
many-to-many. In this case we also need to define an additional class called Groupuser.

View File

@ -32,7 +32,9 @@ function render($title,$t,$e) {
if(file_exists("codes/$title - $t.php")) {
print "<table border=1 class='dashed' cellpadding=0 cellspacing=0>";
print "<tr><td>";
$c = file_get_contents("codes/$title - $t.php");
$c = file_get_contents("codes/$title - $t.php");
$c = trim($c);
$h->loadString($c);
print $h->toHtml();
print "</td></tr>";
@ -52,13 +54,18 @@ function render_block($name) {
}
}
if(file_exists("codes/$name.php")) {
$c = file_get_contents("codes/$name.php");
$c = trim($c);
if( ! empty($c)) {
$h->loadString($c);
print "<table width=500 border=1 class='dashed' cellpadding=0 cellspacing=0>";
print "<tr><td>";
$c = file_get_contents("codes/$name.php");
$h->loadString($c);
print $h->toHtml();
print "</td></tr>";
print "</table>";
}
}
}
function array2path($array, $path = '') {
@ -189,7 +196,8 @@ $menu = array("Getting started" =>
"Creating related records",
"Retrieving related records",
"Updating related records",
"Deleting related records"),
"Deleting related records",
"Working with associations"),
"Inheritance" =>
array("One table many classes",
"One table one class",
@ -315,6 +323,7 @@ $menu = array("Getting started" =>
"Real world examples" => array("User management system","Forum application","Album lister")
);
?>
@ -352,14 +361,16 @@ $menu = array("Getting started" =>
if( ! file_exists("docs/$title - $k - $v2.php")) {
$missing[0]++;
$str .= " [ <font color='red'>doc</font> ] ";
//touch("docs/$title - $k - $v2.php");
}
if( ! file_exists("codes/$title - $k - $v2.php")) {
$missing[1]++;
$str .= " [ <font color='red'>code</font> ] ";
//touch("codes/$title - $k - $v2.php");
}
$e = implode(".",array($i,$i2,$i3));
print "<dd><dd>".$e." <a href=\"".$_SERVER['PHP_SELF']."?index=$i.$i2#$e\">".$v2."</a><br>\n";
print "<dd><dd>".$e." <a href=\"".$_SERVER['PHP_SELF']."?index=$i.$i2#$e\">".$v2."</a>$str<br>\n";
$i3++;
}
} else {
@ -367,12 +378,14 @@ $menu = array("Getting started" =>
if( ! file_exists("docs/$title - $t.php")) {
$missing[0]++;
$str .= " [ <font color='red'>doc</font> ] ";
//touch("docs/$title - $t.php");
}
if( ! file_exists("codes/$title - $t.php")) {
$missing[1]++;
$str .= " [ <font color='red'>code</font> ] ";
//touch("codes/$title - $t.php");
}
print "<dd>".$e." <a href=\"".$_SERVER['PHP_SELF']."?index=$i#$e\">".$t."</a><br>\n";
print "<dd>".$e." <a href=\"".$_SERVER['PHP_SELF']."?index=$i#$e\">".$t."</a>$str<br>\n";
}
$i2++;
}