fix SQL error on install for PostgreSQL or MySQL running strict-mode

This commit is contained in:
Ralf Becker 2014-11-10 15:37:52 +00:00
parent f7a508608b
commit f5ee6afc6b

View File

@ -1001,7 +1001,19 @@ class emailadmin_account implements ArrayAccess
$data['acc_modified'] = time(); $data['acc_modified'] = time();
// store account data // store account data
if (!($data['acc_id'] > 0)) unset($data['acc_id']); if (!($data['acc_id'] > 0))
{
// set not set values which, are NOT NULL and therefore would give an SQL error
$td = self::$db->get_table_definitions('emailadmin', self::TABLE);
foreach($td['fd'] as $col => $def)
{
if (!isset($data[$col]) && $def['nullable'] === false && !isset($def['default']))
{
$data[$col] = null;
}
}
unset($data['acc_id']);
}
$where = $data['acc_id'] > 0 ? array('acc_id' => $data['acc_id']) : false; $where = $data['acc_id'] > 0 ? array('acc_id' => $data['acc_id']) : false;
self::$db->insert(self::TABLE, $data, $where, __LINE__, __FILE__, self::APP); self::$db->insert(self::TABLE, $data, $where, __LINE__, __FILE__, self::APP);
if (!($data['acc_id'] > 0)) if (!($data['acc_id'] > 0))