From 3489451b64b57b70e39045ca51a8b4b08dc90f79 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 6 Jun 2003 13:53:29 +0000 Subject: [PATCH] set date value to null when blank --- lib/archiving/ArchivingDateSettings.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/archiving/ArchivingDateSettings.inc b/lib/archiving/ArchivingDateSettings.inc index edac8db..1f11a66 100644 --- a/lib/archiving/ArchivingDateSettings.inc +++ b/lib/archiving/ArchivingDateSettings.inc @@ -38,7 +38,7 @@ class ArchivingDateSettings { // primary key not set as this is not stored yet $this->iId = -1; - $this->dExpirationDate = $dNewExpirationDate; + $this->setExpirationDate($dNewExpirationDate); $this->iTimePeriodID = $iNewTimePeriodID; } @@ -62,7 +62,7 @@ class ArchivingDateSettings { * @param date the new expiration date */ function setExpirationDate($dNewExpirationDate){ - $this->dExpirationDate = $dNewExpirationDate; + $this->dExpirationDate = strlen($dNewExpirationDate) == 0 ? "NULL" : "'$dNewExpirationDate'"; } /** @@ -91,8 +91,10 @@ class ArchivingDateSettings { //if the id >= 0, then the object has already been created if ($this->iId < 0) { $sql = $default->db; - $result = $sql->query("INSERT INTO $default->owl_archiving_date_settings_table (expiration_date, time_period_id) " . - "VALUES ('$this->dExpirationDate', $this->iTimePeriodID)"); + $sQuery = "INSERT INTO $default->owl_archiving_date_settings_table (expiration_date, time_period_id) " . + "VALUES ($this->dExpirationDate, $this->iTimePeriodID)"; + $result = $sql->query($sQuery); + $default->log->info($sQuery); if ($result) { //set the current primary key $this->iId = $sql->insert_id(); @@ -113,9 +115,10 @@ class ArchivingDateSettings { if ($this->iId >= 0) { $sql = $default->db; $sQuery = "UPDATE $default->owl_archiving_date_settings_table SET " . - "expiration_date = '$this->dExpirationDate', " . + "expiration_date = $this->dExpirationDate, " . "time_period_id = $this->iTimePeriodID " . "WHERE id = $this->iId"; + $default->log->info($sQuery); $result = $sql->query($sQuery); if ($result) { return true; -- libgit2 0.21.4