Check if Apostrophes is needed when null is given

This commit is contained in:
Beu 2023-01-16 18:43:47 +01:00
parent 75866b6954
commit 16889f1a6a
1 changed files with 4 additions and 0 deletions

View File

@ -49,6 +49,10 @@ abstract class Builder
*/
public static function escapeText($text = "", $addApostrophes = true)
{
if ($text === null) {
if ($addApostrophes) return "\"\"";
return "";
}
$dangers = array('\\', '"', "\n");
$replacements = array('\\\\', '\\"', '\\n');
$escapedText = str_ireplace($dangers, $replacements, $text);