Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NULLable properties of Sprig_Field_NativeTimestamp type - incorrect value written to the database ('0000-00-00 00:00:00' instead of NULL) #86

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion classes/sprig/field/nativetimestamp.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
*
* @package Sprig
* @author Marcus Cobden
* @author Tomasz Jaskowski
* @copyright (c) 2010 Marcus Cobden
* @license MIT
*/
class Sprig_Field_NativeTimestamp extends Sprig_Field_Timestamp {

public function _database_wrap($value)
{
return new Database_Expression('FROM_UNIXTIME('. (int) $value . ')');
if ($value === null) {
return new Database_Expression('NULL');
} else {
return new Database_Expression('FROM_UNIXTIME('. (int) $value . ')');
}
}

public function _database_unwrap($value)
Expand Down