Commit 3489451b64b57b70e39045ca51a8b4b08dc90f79
1 parent
16233e80
set date value to null when blank
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2096 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
8 additions
and
5 deletions
lib/archiving/ArchivingDateSettings.inc
| ... | ... | @@ -38,7 +38,7 @@ class ArchivingDateSettings { |
| 38 | 38 | |
| 39 | 39 | // primary key not set as this is not stored yet |
| 40 | 40 | $this->iId = -1; |
| 41 | - $this->dExpirationDate = $dNewExpirationDate; | |
| 41 | + $this->setExpirationDate($dNewExpirationDate); | |
| 42 | 42 | $this->iTimePeriodID = $iNewTimePeriodID; |
| 43 | 43 | } |
| 44 | 44 | |
| ... | ... | @@ -62,7 +62,7 @@ class ArchivingDateSettings { |
| 62 | 62 | * @param date the new expiration date |
| 63 | 63 | */ |
| 64 | 64 | function setExpirationDate($dNewExpirationDate){ |
| 65 | - $this->dExpirationDate = $dNewExpirationDate; | |
| 65 | + $this->dExpirationDate = strlen($dNewExpirationDate) == 0 ? "NULL" : "'$dNewExpirationDate'"; | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
| ... | ... | @@ -91,8 +91,10 @@ class ArchivingDateSettings { |
| 91 | 91 | //if the id >= 0, then the object has already been created |
| 92 | 92 | if ($this->iId < 0) { |
| 93 | 93 | $sql = $default->db; |
| 94 | - $result = $sql->query("INSERT INTO $default->owl_archiving_date_settings_table (expiration_date, time_period_id) " . | |
| 95 | - "VALUES ('$this->dExpirationDate', $this->iTimePeriodID)"); | |
| 94 | + $sQuery = "INSERT INTO $default->owl_archiving_date_settings_table (expiration_date, time_period_id) " . | |
| 95 | + "VALUES ($this->dExpirationDate, $this->iTimePeriodID)"; | |
| 96 | + $result = $sql->query($sQuery); | |
| 97 | + $default->log->info($sQuery); | |
| 96 | 98 | if ($result) { |
| 97 | 99 | //set the current primary key |
| 98 | 100 | $this->iId = $sql->insert_id(); |
| ... | ... | @@ -113,9 +115,10 @@ class ArchivingDateSettings { |
| 113 | 115 | if ($this->iId >= 0) { |
| 114 | 116 | $sql = $default->db; |
| 115 | 117 | $sQuery = "UPDATE $default->owl_archiving_date_settings_table SET " . |
| 116 | - "expiration_date = '$this->dExpirationDate', " . | |
| 118 | + "expiration_date = $this->dExpirationDate, " . | |
| 117 | 119 | "time_period_id = $this->iTimePeriodID " . |
| 118 | 120 | "WHERE id = $this->iId"; |
| 121 | + $default->log->info($sQuery); | |
| 119 | 122 | $result = $sql->query($sQuery); |
| 120 | 123 | if ($result) { |
| 121 | 124 | return true; | ... | ... |