Commit 3489451b64b57b70e39045ca51a8b4b08dc90f79

Authored by michael
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
lib/archiving/ArchivingDateSettings.inc
@@ -38,7 +38,7 @@ class ArchivingDateSettings { @@ -38,7 +38,7 @@ class ArchivingDateSettings {
38 38
39 // primary key not set as this is not stored yet 39 // primary key not set as this is not stored yet
40 $this->iId = -1; 40 $this->iId = -1;
41 - $this->dExpirationDate = $dNewExpirationDate; 41 + $this->setExpirationDate($dNewExpirationDate);
42 $this->iTimePeriodID = $iNewTimePeriodID; 42 $this->iTimePeriodID = $iNewTimePeriodID;
43 } 43 }
44 44
@@ -62,7 +62,7 @@ class ArchivingDateSettings { @@ -62,7 +62,7 @@ class ArchivingDateSettings {
62 * @param date the new expiration date 62 * @param date the new expiration date
63 */ 63 */
64 function setExpirationDate($dNewExpirationDate){ 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,8 +91,10 @@ class ArchivingDateSettings {
91 //if the id >= 0, then the object has already been created 91 //if the id >= 0, then the object has already been created
92 if ($this->iId < 0) { 92 if ($this->iId < 0) {
93 $sql = $default->db; 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 if ($result) { 98 if ($result) {
97 //set the current primary key 99 //set the current primary key
98 $this->iId = $sql->insert_id(); 100 $this->iId = $sql->insert_id();
@@ -113,9 +115,10 @@ class ArchivingDateSettings { @@ -113,9 +115,10 @@ class ArchivingDateSettings {
113 if ($this->iId >= 0) { 115 if ($this->iId >= 0) {
114 $sql = $default->db; 116 $sql = $default->db;
115 $sQuery = "UPDATE $default->owl_archiving_date_settings_table SET " . 117 $sQuery = "UPDATE $default->owl_archiving_date_settings_table SET " .
116 - "expiration_date = '$this->dExpirationDate', " . 118 + "expiration_date = $this->dExpirationDate, " .
117 "time_period_id = $this->iTimePeriodID " . 119 "time_period_id = $this->iTimePeriodID " .
118 "WHERE id = $this->iId"; 120 "WHERE id = $this->iId";
  121 + $default->log->info($sQuery);
119 $result = $sql->query($sQuery); 122 $result = $sql->query($sQuery);
120 if ($result) { 123 if ($result) {
121 return true; 124 return true;