From 4458f366f93d93993ec092442d00f76485db43f5 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Thu, 7 Jan 2016 13:06:47 +0900 Subject: [PATCH] Bug fixes for data insert with interval fields in form generate - if interval is emtpy set NULL - do some clean up for pk return data from the form/db array io part --- www/admin/table_arrays/array_edit_users.inc | 1 + www/libs/Class.DB.Array.IO.inc | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/www/admin/table_arrays/array_edit_users.inc b/www/admin/table_arrays/array_edit_users.inc index c9b86a9a..1f0cd95e 100644 --- a/www/admin/table_arrays/array_edit_users.inc +++ b/www/admin/table_arrays/array_edit_users.inc @@ -34,6 +34,7 @@ 'output_name' => 'Password change interval', 'error_check' => 'intervalshort', // can be any date length format. n Y/M/D [not H/M/S], only one set, no combination 'type' => 'text', + 'interval' => 1, // interval needs NULL write for empty 'size' => 5, // make it 5 chars long 'length' => 5 ), diff --git a/www/libs/Class.DB.Array.IO.inc b/www/libs/Class.DB.Array.IO.inc index 00aacd4e..2faa225a 100644 --- a/www/libs/Class.DB.Array.IO.inc +++ b/www/libs/Class.DB.Array.IO.inc @@ -429,6 +429,13 @@ $this->debug('write_check', "[$column][".$this->table_array[$column]["value"]."] $_value = $this->table_array[$column]["value"]; $q_data .= $_value; } + elseif ($this->table_array[$column]["interval"]) + { + // for interval we check if no value, then we set null + if (!$this->table_array[$column]["value"]) + $_value = 'NULL'; + $q_data .= $_value; + } else // normal string { @@ -500,7 +507,10 @@ $this->debug('write_check', "[$column][".$this->table_array[$column]["value"]."] } // set primary key if ($insert) - $this->ok = $this->table_array[$this->pk_name]["value"] = $this->insert_id; + { + $this->table_array[$this->pk_name]["value"] = $this->insert_id; + $this->ok = $this->insert_id; + } // return the table if needed return $this->table_array; }