More helpful error messages for database errors.
This commit is contained in:
parent
02752798a9
commit
e1df4678ac
@ -183,7 +183,7 @@ class Database
|
|||||||
{
|
{
|
||||||
case 'int':
|
case 'int':
|
||||||
if ((!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) && $replacement !== 'NULL')
|
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';
|
return $replacement !== 'NULL' ? (string) (int) $replacement : 'NULL';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ class Database
|
|||||||
foreach ($replacement as $key => $value)
|
foreach ($replacement as $key => $value)
|
||||||
{
|
{
|
||||||
if (!is_numeric($value) || (string) $value !== (string) (int) $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;
|
$replacement[$key] = (string) (int) $value;
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ class Database
|
|||||||
return implode(', ', $replacement);
|
return implode(', ', $replacement);
|
||||||
}
|
}
|
||||||
else
|
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;
|
break;
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ class Database
|
|||||||
return implode(', ', $replacement);
|
return implode(', ', $replacement);
|
||||||
}
|
}
|
||||||
else
|
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;
|
break;
|
||||||
|
|
||||||
case 'date':
|
case 'date':
|
||||||
@ -234,7 +234,7 @@ class Database
|
|||||||
elseif ($replacement === 'NULL')
|
elseif ($replacement === 'NULL')
|
||||||
return 'NULL';
|
return 'NULL';
|
||||||
else
|
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;
|
break;
|
||||||
|
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
@ -245,12 +245,12 @@ class Database
|
|||||||
elseif ($replacement === 'NULL')
|
elseif ($replacement === 'NULL')
|
||||||
return 'NULL';
|
return 'NULL';
|
||||||
else
|
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;
|
break;
|
||||||
|
|
||||||
case 'float':
|
case 'float':
|
||||||
if (!is_numeric($replacement) && $replacement !== 'NULL')
|
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';
|
return $replacement !== 'NULL' ? (string) (float) $replacement : 'NULL';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user