Skip to content

Commit

Permalink
fix: error undefined quote method
Browse files Browse the repository at this point in the history
  • Loading branch information
darkterminal committed Jun 25, 2024
1 parent 6cf89f2 commit ff45ad3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Database/LibSQLConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,21 @@ protected function isUniqueConstraintError(Exception $exception): bool
{
return boolval(preg_match('#(column(s)? .* (is|are) not unique|UNIQUE constraint failed: .*)#i', $exception->getMessage()));
}

public function escapeString($value)
{
// DISCUSSION: Open PR if you have best approach
$escaped_value = str_replace(
["\\", "\x00", "\n", "\r", "\x1a", "'", '"'],
["\\\\", "\\0", "\\n", "\\r", "\\Z", "\\'", '\\"'],
$value
);

return $escaped_value;
}

public function quote(string $value): string
{
return $this->escapeString($value);
}
}
17 changes: 17 additions & 0 deletions src/Database/LibSQLDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ public function sync(): void
$this->db->sync();
}

public static function escapeString($value)
{
// DISCUSSION: Open PR if you have best approach
$escaped_value = str_replace(
["\\", "\x00", "\n", "\r", "\x1a", "'", '"'],
["\\\\", "\\0", "\\n", "\\r", "\\Z", "\\'", '\\"'],
$value
);

return $escaped_value;
}

public function quote(string $value): string
{
return self::escapeString($value);
}

/**
* Check the connection mode based on the provided path.
*
Expand Down

0 comments on commit ff45ad3

Please sign in to comment.