if ($info['type'] == 'boolean') {
$update[] = sprintf("%s=%d", $field, $_POST[$field] == 'on'?1:0);
- } elseif ($info['type'] == 'number' || $info['type'] == 'hidden' || ($info['type'] == 'select' && $info['options_string'] !== true)) {
+ } elseif ($info['type'] == 'hidden')) {
+ if (empty($_POST[$field]) && $info['null'] === true)
+ $update[] = sprintf("%s=NULL", $field);
+ else {
+ if ($info['subtype'] == 'string')
+ $update[] = sprintf("%s='%s'", $field, pg_escape_string($_POST[$field]));
+ else
+ $update[] = sprintf("%s=%d", $field, $_POST[$field]);
+ }
+ } elseif ($info['type'] == 'number' || ($info['type'] == 'select' && $info['options_string'] !== true)) {
if (empty($_POST[$field]) && $info['null'] === true)
$update[] = sprintf("%s=NULL", $field);
else
if ($info['type'] == 'boolean') {
$fields[] = $field;
$values[] = $_POST[$field] == 'on'?1:0;
- } elseif ($info['type'] == 'number' || $info['type'] == 'hidden' || ($info['type'] == 'select' && $info['options_string'] !== true)) {
+ } elseif ($info['type'] == 'hidden') {
+ $fields[] = $field;
+ if (empty($_POST[$field]) && $info['null'] === true)
+ $values[] = 'NULL';
+ else {
+ if ($info['subtype'] == 'string')
+ $values[] = sprintf("'%s'", pg_escape_string($_POST[$field]));
+ else
+ $values[] = intval($_POST[$field]);
+ }
+ } elseif ($info['type'] == 'number' || ($info['type'] == 'select' && $info['options_string'] !== true)) {
$fields[] = $field;
if (empty($_POST[$field]) && $info['null'] === true)
$values[] = 'NULL';