-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
94 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
/** | ||
* @author Kirill "Nemoden" K | ||
* $ Date: Mon 26 Mar 2012 02:12:57 PM VLAST $ | ||
*/ | ||
|
||
class DbDate extends DateTime { | ||
private $_format = 'Y-m-d'; | ||
public function __toString() { | ||
return (string)parent::format($this->_format); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
class ResolverException extends Exception { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* @author Kirill "Nemoden" K | ||
* $ Date: Mon 26 Mar 2012 01:39:00 PM VLAST $ | ||
*/ | ||
require_once '../Model.php'; | ||
require_once '../exceptions/ResolverException.php'; | ||
|
||
class Person extends Model { | ||
protected $_table = 'people'; | ||
protected $_schema = 'test'; | ||
protected $_pk = 'id'; | ||
|
||
protected function resolvers() { | ||
return array('age' => 'resolveAge'); | ||
} | ||
|
||
protected function resolveAge() { | ||
if (!isset($this->birthday) || (!($this->birthday instanceof DateTime))) { | ||
throw new ResolverException('Birthday field is not set or not DateTime instance'); | ||
} | ||
$now = new DateTime(); | ||
$interval = date_diff($now, $this->birthday); | ||
$this->age = $interval->y; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b430f6e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Клевый комит!