Created
June 1, 2010 21:14
-
-
Save ixti/421508 to your computer and use it in GitHub Desktop.
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
<?php | |
class SomeModel extends Doctrine_Record | |
{ | |
public function setTableDefinition() | |
{ | |
// ... | |
$this->hasColumn('some_date', 'date', null, array('notnull' => true, 'notblank' => true)); | |
// ... | |
} | |
// ... | |
public function getSomeDate() | |
{ | |
$value = $this->_get('some_date'); | |
return ($value) ? new Zend_Date($value, 'YYYY-MM-dd') : $value; | |
} | |
public function setSomeDate($value) | |
{ | |
if ($value instanceof Zend_Date) { | |
$value = $value->toString('YYYY-MM-dd'); | |
} else if (null !== $value && false === Zend_Date::isDate($value, 'YYYY-MM-dd')) { | |
throw new App_Exception('Unsupported type or format of some_date'); | |
} | |
$this->_set('some_date', $value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment