Revision: 1387
http://mrbs.svn.sourceforge.net/mrbs/?rev=1387&view=rev
Author: cimorrison
Date: 2010-07-26 09:57:13 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
Fixed a bug that gave an SQL error if a field intended to be a boolean (ie was
a smallint or less) was designated "NOT NULL".
Modified Paths:
--------------
mrbs/branches/custom_entry_fields/web/mrbs_sql.inc
Modified: mrbs/branches/custom_entry_fields/web/mrbs_sql.inc
===================================================================
--- mrbs/branches/custom_entry_fields/web/mrbs_sql.inc 2010-07-25 22:49:38 UTC
(rev 1386)
+++ mrbs/branches/custom_entry_fields/web/mrbs_sql.inc 2010-07-26 09:57:13 UTC
(rev 1387)
@@ -275,9 +275,11 @@
{
$fields = sql_field_info($tbl_entry);
$field_natures = array();
+ $field_lengths = array();
foreach ($fields as $field)
{
$field_natures[$field['name']] = $field['nature'];
+ $field_lengths[$field['name']] = $field['length'];
}
foreach ($custom_fields as $key => $value)
{
@@ -286,7 +288,17 @@
case 'integer':
if (!isset($value))
{
- $value = 'NULL';
+ // If the field length is greater than 2 bytes then this is a
genuine
+ // integer and we will write NULL to the database. We need to
do this
+ // because in many cases we will want to distinguish between
NULL (no
+ // value has yet been assigned) and 0 (no units of this resource
are
+ // required.
+ //
+ // However if the field length is 2 bytes or less then it is to
be treated
+ // as a boolean and we only represent the values TRUE (1) or
FALSE (0).
+ // So we will write out the value 0 rather than NULL in case the
database
+ // field has been set to "NOT NULL".
+ $value = ($field_lengths[$key] > 2) ? 'NULL' : 0;
}
break;
default:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits