1
0
mirror of synced 2024-12-13 06:46:03 +03:00

AccessorInvoker code example

This commit is contained in:
zYne 2006-09-12 17:52:23 +00:00
parent 6e7cc43204
commit 51fbbb05d6
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
class User {
public function setTableDefinition() {
$this->hasColumn("name", "string", 200);
$this->hasColumn("password", "string", 32);
}
public function setPassword($password) {
return md5($password);
}
public function getName($name) {
return strtoupper($name);
}
}
$user = new User();
$user->name = 'someone';
print $user->name; // someone
$user->password = '123';
print $user->password; // 123
$user->setAttribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker());
print $user->name; // SOMEONE
$user->password = '123';
print $user->password; // 202cb962ac59075b964b07152d234b70
?>