More helpful error messages for database errors.

This commit is contained in:
Aaron van Geffen 2016-09-02 11:46:53 +02:00
parent 02752798a9
commit e1df4678ac

View File

@ -183,7 +183,7 @@ class Database
{
case 'int':
if ((!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) && $replacement !== 'NULL')
trigger_error('Wrong value type sent to the database. Integer expected.', E_USER_ERROR);
trigger_error('Wrong value type sent to the database for field: ' . $matches[2] . '. Integer expected.', E_USER_ERROR);
return $replacement !== 'NULL' ? (string) (int) $replacement : 'NULL';
break;
@ -201,7 +201,7 @@ class Database
foreach ($replacement as $key => $value)
{
if (!is_numeric($value) || (string) $value !== (string) (int) $value)
trigger_error('Wrong value type sent to the database. Array of integers expected.', E_USER_ERROR);
trigger_error('Wrong value type sent to the database for field: ' . $matches[2] . '. Array of integers expected.', E_USER_ERROR);
$replacement[$key] = (string) (int) $value;
}
@ -209,7 +209,7 @@ class Database
return implode(', ', $replacement);
}
else
trigger_error('Wrong value type sent to the database. Array of integers expected.', E_USER_ERROR);
trigger_error('Wrong value type sent to the database for field: ' . $matches[2] . '. Array of integers expected.', E_USER_ERROR);
break;
@ -225,7 +225,7 @@ class Database
return implode(', ', $replacement);
}
else
trigger_error('Wrong value type sent to the database. Array of strings expected.', E_USER_ERROR);
trigger_error('Wrong value type sent to the database for field: ' . $matches[2] . '. Array of strings expected.', E_USER_ERROR);
break;
case 'date':
@ -234,7 +234,7 @@ class Database
elseif ($replacement === 'NULL')
return 'NULL';
else
trigger_error('Wrong value type sent to the database. Date expected.', E_USER_ERROR);
trigger_error('Wrong value type sent to the database for field: ' . $matches[2] . '. Date expected.', E_USER_ERROR);
break;
case 'datetime':
@ -245,12 +245,12 @@ class Database
elseif ($replacement === 'NULL')
return 'NULL';
else
trigger_error('Wrong value type sent to the database. DateTime expected.', E_USER_ERROR);
trigger_error('Wrong value type sent to the database for field: ' . $matches[2] . '. DateTime expected.', E_USER_ERROR);
break;
case 'float':
if (!is_numeric($replacement) && $replacement !== 'NULL')
trigger_error('Wrong value type sent to the database. Floating point number expected.', E_USER_ERROR);
trigger_error('Wrong value type sent to the database for field: ' . $matches[2] . '. Floating point number expected.', E_USER_ERROR);
return $replacement !== 'NULL' ? (string) (float) $replacement : 'NULL';
break;